diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-02-01 13:58:10 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-02-01 15:06:00 +0300 |
commit | 9fa628f35be31a18edfdb1e1fca8a6bd3b6b453c (patch) | |
tree | 999052f41e41117200da4bb1d177ffc6a7ff9fab /doc | |
parent | 8c7e1b648b782542c4906ccb849c39b167265558 (diff) |
mathutils: added exponential map to Quaternion
Added conversion to and from exponential map representation. This
representation is useful for interpolation of > 2 quaternions, or in
PD controllers.
Implementation in C functions quat_to_expmap,
quat_normalized_to_expmap, and expmap_to_quat with Python API, unit
tests and documentation.
Added Quaternion.to_exponential_map() and Quaternion(3-vector) to
Python API.
Reviewers: campbellbarton
Projects: #bf_blender
Differential Revision: https://developer.blender.org/D1049
Diffstat (limited to 'doc')
-rw-r--r-- | doc/python_api/examples/mathutils.Quaternion.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/python_api/examples/mathutils.Quaternion.py b/doc/python_api/examples/mathutils.Quaternion.py index d8c696e6ba6..7e5538b7a96 100644 --- a/doc/python_api/examples/mathutils.Quaternion.py +++ b/doc/python_api/examples/mathutils.Quaternion.py @@ -21,3 +21,12 @@ 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), ))) + +# multiple rotations can be interpolated using the exponential map +quat_c = mathutils.Quaternion((1.0, 0.0, 0.0), math.radians(15.0)) +exp_avg = (quat_a.to_exponential_map() + + quat_b.to_exponential_map() + + quat_c.to_exponential_map()) / 3.0 +quat_avg = mathutils.Quaternion(exp_avg) +print("Average rotation:") +print(quat_avg) |