~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to doc/python_api/examples/mathutils.Euler.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import mathutils
 
2
import math
 
3
 
 
4
# create a new euler with default axis rotation order
 
5
eul = mathutils.Euler((0.0, math.radians(45.0), 0.0), 'XYZ')
 
6
 
 
7
# rotate the euler
 
8
eul.rotate_axis(math.radians(10.0), 'Z')
 
9
 
 
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])
 
14
 
 
15
# components of an existing euler can be set
 
16
eul[:] = 1.0, 2.0, 3.0
 
17
 
 
18
# components of an existing euler can use slice notation to get a tuple
 
19
print("Values: %f, %f, %f" % eul[:])
 
20
 
 
21
# the order can be set at any time too
 
22
eul.order = 'ZYX'
 
23
 
 
24
# eulers can be used to rotate vectors
 
25
vec = mathutils.Vector((0.0, 0.0, 1.0))
 
26
vec.rotate(eul)
 
27
 
 
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()