Re: [eigen] Rotations and unit vectors

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Tue, May 14, 2013 at 6:14 PM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> W.r.t. Quaternion there is the problem that it is only somehow intended to
> be a unit quaternion but never explicitly named so.
> There are also users who like to use non-unit Quaternions:
> http://eigen.tuxfamily.org/bz/show_bug.cgi?id=560

Even though there is a related bug entry, I continue here to give it
more visibility.

> If it actually was a unit quaternion, then normalize(), normalized(), norm()
> and squaredNorm() could be essentially NOPs/accessors/const-expressions, and
> inverse() would be just an alias for conjugate().
>
> However, functions such as toRotationMatrix() or q * v give undefined (or
> unintended) behavior for non-unit quaternions).
>
> I'd like to vote again for adding a new class UnitQuaternion which does
> run-time checks for unity (and exploits all reasonable optimizations) and
> either deprecate the current Quaternion class to introduce a new class
> GeneralQuaternion, which works as suggested in bug 560, or let the current
> Quaternion class behave like a general quaternion.
> That also means that q*v shall return (q*[0;v]*q.conjugate()).vec() or
> should not be implemented at all.
>
> Unfortunately, I think that deprecating/deleting/redefining Quaternion is a
> rather heavy step and at least deleting/redefining must wait until Eigen
> 4.0, to ensure API compatibility.

Actually, a quick look at the current Quaternion class make me think
that we should be able to generalize the current Quaternion class to
be of general purpose without breaking or penalizing existing code.
Only a few members would be marked as deprecated with an advise to
move to the UnitQuaternion class. They include:

- conversions from/to rotation matrices
- slerp
- setFromTwoVectors
- angularDistance
- operator*(vector)

We should also think about the conversion from Quaternion to
UnitQuaternion. For instance:
 - Shall Quaternion::normalized() returns a UnitQuaternion? I guess not.
 - The conversion from a Quaternion to a UnitQuaternion should
probably trigger an implicit normalization that could be avoided via a
Quaternion::asUnitQuaternion() cast function?

cheers,
gael



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/