diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-17 06:20:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-17 06:20:53 +0400 |
commit | 67c15da97de7644fc4deb3ab1b03c3db22f1f647 (patch) | |
tree | 2381852d6f5957db9c20c379cd3559df79e24ac4 /doc/python_api/examples/mathutils.Quaternion.py | |
parent | 8fae0c6d7e0d24bfa6c12e2121c5fa7a62440141 (diff) |
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.
Diffstat (limited to 'doc/python_api/examples/mathutils.Quaternion.py')
-rw-r--r-- | doc/python_api/examples/mathutils.Quaternion.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/doc/python_api/examples/mathutils.Quaternion.py b/doc/python_api/examples/mathutils.Quaternion.py index bc7702c1d53..d8c696e6ba6 100644 --- a/doc/python_api/examples/mathutils.Quaternion.py +++ b/doc/python_api/examples/mathutils.Quaternion.py @@ -1,3 +1,23 @@ import mathutils +import math -# todo +# a new rotation 90 degrees about the Y axis +quat_a = mathutils.Quaternion((0.7071068, 0.0, 0.7071068, 0.0)) + +# passing values to Quaternion's directly can be confusing so axis, angle +# is supported for initializing too +quat_b = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0)) + +print("Check quaternions match", quat_a == quat_b) + +# like matrices, quaternions can be multiplied to accumulate rotational values +quat_a = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0)) +quat_b = mathutils.Quaternion((0.0, 0.0, 1.0), math.radians(45.0)) +quat_out = quat_a * quat_b + +# print the quat, euler degrees for mear mortals and (axis, angle) +print("Final Rotation:") +print(quat_out) +print("%.2f, %.2f, %.2f" % tuple(math.degrees(a) for a in quat_out.to_euler())) +print("(%.2f, %.2f, %.2f), %.2f" % (quat_out.axis[:] + + (math.degrees(quat_out.angle), ))) |