Skip to content

Allow standard linear algebra operations for quaternions

Submitted by Boris D.

Assigned to Nobody

Link to original bugzilla bug (#560)

Description

It seems it is currently not allowed by Eigen to multiply a quaternion by a scalar, or add quaternions together (simple component-wise operations).

Indeed, if a quaternion is seen as a 3D rotation, these operations do not make sense, but quaternions could be used for other purposes, and even if it is used to represent rotations, algorithms might use such operations followed by normalization (my application case was an integration step in a physics simulator).

I guess it should be easy to implement these:

Quaternion & operator+(Quaternion & q);

Quaternion & operator+=(Quaternion & q);

Quaternion & operator*(Scalar s);

Quaternion & operator*(Scalar s, Quaternion & q);

Quaternion & operator*=(Scalar s);

But I could not figure out how to do it myself, not being familiar with the Eigen's code source structures and patterns, hence directly used code like:

q.w() += other.w();

q.x() += other.x();

q.y() += other.y();

q.z() += other.z();

That unfortunately does not take advantage of vectorization.

Depends on

#758 (closed)

Blocking

#458 #459 #601 #719 #814