Page MenuHome

mathutils: added Quaternion.{to,from}_exponential_map

Authored by Sybren A. Stüvel (sybren) on Jan 31 2015, 10:16 PM.



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(...) and expmap_to_quat(...) with Python API, unit tests and documentation.

Diff Detail

rB Blender

Event Timeline

Sybren A. Stüvel (sybren) retitled this revision from to mathutils: added Quaternion.{to,from}_exponential_map.
Sybren A. Stüvel (sybren) updated this object.

Removed superfluous newline.

Generally very good, one concern about initialization though.


this isnt so bad, but its not in keeping with current API conventions.

The main thing that I find confusing its its uses names which are normally symmetrical - to/from, where only one is a class method.

So you could do:

vec = q1.to_exponential_map()
q2.from_exponential_map(vec)  # <-- this wouldn't edit q2, as one might expect.

One convention Matrix class uses camelcap's to distinguish constructors eg: Matrix.Rotation/Translation/Shear/OrthoProjection...

We could have Quaternion.FromExponentialMap... but not especially keen about this...

Another alternative could be to have Vector.to_quaternion() though its a bit obscure and requires creating a vector first.

While its a bit awkward, Currently we're overloading Quaternion's __init__ args to allow axis/angle or a quaternion args.

We could allow a single vector, where (4d == quat, 3d == expmap).

Out of the options listed, I'd prefer this the most. but open to feedback too.

Sybren A. Stüvel (sybren) edited edge metadata.

I share your concern. I've also been looking at FromExponentialMap in line with the matrix class methods, but I wasn't fond of that either. This update extends the constructor instead.

Campbell Barton (campbellbarton) requested changes to this revision.Feb 1 2015, 11:52 AM
Campbell Barton (campbellbarton) edited edge metadata.

Minor change regarding documentation


This highlights that we don't have any docs __init__ which is weak (should document Quaternion(axis, angle) too).

Prefer this info be added to quaternion_doc (which is currently one line).

This revision now requires changes to proceed.Feb 1 2015, 11:52 AM
This revision was automatically updated to reflect the committed changes.

Addressed Campbell's issue, and committed to the temp-mathutils branch for some more tweaks & easier collaboration.