Method to compute (q^-1 p) or (q p^-1) directly
See original GitHub issueI’m looking for a method to compute the following for quaternions p
and q
:
r = p q p^-1
The combinations q p^-1
and q^-1 p
seem to come up quite commonly (for the rotation between two quaternions), so it would increase efficiency if there were methods that computed these directly. (This would increase the number of multiplication methods by a factor of 3 over the current mul
and premul
variants – with new variants for inverting this
and inverting the passed parameter.)
The JOML API lets you pre-allocate objects to avoid allocating intermediate objects, but then to compute a product with an inverted parameter, you have to pre-allocate a quaternion just to do the inversion (or deal with there being an extra intermediate object allocated). In the worst case, it is the following (I’m sure one or two of the intermediate objects could be reused with some smarter ordering of operations):
Quaterniond r = p.mul(q.mul(p.invert(new Quaterniond()), new Quaterniond()), new Quaterniond());
instead of something like
Quaterniond r = p.mul(q.mulByInverted(p, new Quaterniond()), new Quaterniond());
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Changes will be up with build https://travis-ci.org/JOML-CI/JOML/builds/609934214 on oss.sonatype.org Maven repo as a new 1.9.20-SNAPSHOT version.
I see, you need the “conjugate p by q” operation: https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#The_conjugation_operation I’ll add it to JOML shortly.