geometry icon indicating copy to clipboard operation
geometry copied to clipboard

A more efficient calculation of quaternion inverse

Open AndyZe opened this issue 7 years ago • 3 comments
trafficstars

I'm not an expert on quaternions, but from looking at several online sources, I believe there are 2 equivalent ways to invert a quaternion:

xi+yj+zk - w = -xi-yj-zk+w

The tf source code uses the right-hand method, which is less efficient (3 numbers are negated instead of 1). If everybody agrees, I could make a PR for this.

Relevant stack exchange proofs (wish I had a better reference):

https://math.stackexchange.com/questions/2016282/negative-quaternion

https://math.stackexchange.com/questions/1937833/the-quaternion-matrix-for-a-rotation-of-theta-2-pi?rq=1

AndyZe avatar Nov 05 '18 22:11 AndyZe

This is a fork of the bullet linear math library.

That particular function is here: https://github.com/bulletphysics/bullet3/blob/f7237647fb44f17d791894f5e46be8b80aac3337/src/LinearMath/btQuaternion.h#L497-L505 If that change can be accepted upstream we can backport it here. In general though we've run into trouble diverging from the upstream implementation that I'd rather not encounter again.

tfoote avatar Nov 08 '18 19:11 tfoote

Should we be targeting geometry2 repo for these kinds of improvements? @AndyZe if you're working on moveit1 still using melodic-devel, it will change whether or not its using tf1 or tf2 depending on whether you're compiling on Ubuntu 16.04 (Kinetic) or 18.04 (Melodic)

davetcoleman avatar Feb 20 '19 20:02 davetcoleman

Yes, any changes are highly recommended to be targeted at geometry2 as geometry has been deprecated for quite a long time now.

tfoote avatar Feb 20 '19 22:02 tfoote