4
# create a new euler with default axis rotation order
5
eul = mathutils.Euler((0.0, math.radians(45.0), 0.0), 'XYZ')
8
eul.rotate_axis(math.radians(10.0), 'Z')
10
# you can access its components by attribute or index
11
print("Euler X", eul.x)
12
print("Euler Y", eul[1])
13
print("Euler Z", eul[-1])
15
# components of an existing euler can be set
16
eul[:] = 1.0, 2.0, 3.0
18
# components of an existing euler can use slice notation to get a tuple
19
print("Values: %f, %f, %f" % eul[:])
21
# the order can be set at any time too
24
# eulers can be used to rotate vectors
25
vec = mathutils.Vector((0.0, 0.0, 1.0))
28
# often its useful to convert the euler into a matrix so it can be used as
29
# transformations with more flexibility
30
mat_rot = eul.to_matrix()
31
mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
32
mat = mat_loc * mat_rot.to_4x4()