mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
docs / clenup (no functional code changes)
- added API examples for mathutils.Color/Euler/Quaternion/Matrix. - corrected own bad spelling matricies --> matrices. - minor pep8 edits. - update CMake ignore file list.
This commit is contained in:
parent
8fae0c6d7e
commit
67c15da97d
11 changed files with 123 additions and 12 deletions
|
|
@ -1,3 +1,32 @@
|
|||
import mathutils
|
||||
import math
|
||||
|
||||
# todo
|
||||
# create a new euler with default axis rotation order
|
||||
eul = mathutils.Euler((0.0, math.radians(45.0), 0.0), 'XYZ')
|
||||
|
||||
# rotate the euler
|
||||
eul.rotate_axis(math.radians(10.0), 'Z')
|
||||
|
||||
# you can access its components by attribute or index
|
||||
print("Euler X", eul.x)
|
||||
print("Euler Y", eul[1])
|
||||
print("Euler Z", eul[-1])
|
||||
|
||||
# components of an existing euler can be set
|
||||
eul[:] = 1.0, 2.0, 3.0
|
||||
|
||||
# components of an existing euler can use slice notation to get a tuple
|
||||
print("Values: %f, %f, %f" % eul[:])
|
||||
|
||||
# the order can be set at any time too
|
||||
eul.order = 'ZYX'
|
||||
|
||||
# eulers can be used to rotate vectors
|
||||
vec = mathutils.Vector((0.0, 0.0, 1.0))
|
||||
vec.rotate(eul)
|
||||
|
||||
# often its useful to convert the euler into a matrix so it can be used as
|
||||
# transformations with more flexibility
|
||||
mat_rot = eul.to_matrix()
|
||||
mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
|
||||
mat = mat_loc * mat_rot.to_4x4()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue