# orientation rotate

Hi
I want rotate object by orientation in python
EX :
Rotate Box Angel 45 at Z
Any help for understand orientation or convert Angel to ran in orientation

Orientation (somewhat) explained and py examples.

Very useful file and pdf
for me I don’t understand a lot and I didn’t find this
I need to now angle degree and set angel degree only for Z-axis
Thanks

Well, I took this from Herman’s tutorial and added degree conversion. You’ll need to import math:

``````
def degrees(alpha,beta,gamma):
a = math.cos(alpha)
b = math.sin(alpha)
c = math.cos(beta)
d = math.sin(beta)
e = math.cos(gamma)
f = math.sin(gamma)
bd = b*d
mat = [[c*e, -a*f+b*d*e, b*f+a*d*e],
[c*f, a*e+b*d*f, -b*e+a*d*f],[-d, b*c, a*c]]
return mat

``````

use it as
object.setOrientation(degrees(0,0,45))
If you want to do a local setting you have to multiply by the object’s current matrix so you need a multiply matrix function. I also made it so it rotates clockwise in the 7,1,3 views.

That degree conversion looks redundant, doesn’t it? Oh well. It works and 2 of them I made negatives.