Quaternion: refactor multiplication to matrix multiplication style

Most often the multiplication in convention descriptions and papers is
described in matrix multiplication style like this:
q · p := Q(q)p

Q(q) :=
[q0 −q1 −q2 −q3]
[q1 q0 −q3 q2]
[q2 q3 q0 −q1]
[q3 −q2 q1 q0]

I'm just rearanging the terms such that it's easily comparable with
these definitions additional to it being clearly described by
documenting we use the hamilton convention.
This commit is contained in:
Matthias Grob 2020-05-06 09:57:34 +02:00 committed by Julian Kent
parent d613055462
commit 2bee0d078c

View File

@ -252,14 +252,14 @@ public:
* @param q quaternion to multiply with
* @return product
*/
Quaternion operator*(const Quaternion &q) const
Quaternion operator*(const Quaternion &p) const
{
const Quaternion &p = *this;
const Quaternion &q = *this;
return {
p(0) * q(0) - p(1) * q(1) - p(2) * q(2) - p(3) * q(3),
p(0) * q(1) + p(1) * q(0) + p(2) * q(3) - p(3) * q(2),
p(0) * q(2) - p(1) * q(3) + p(2) * q(0) + p(3) * q(1),
p(0) * q(3) + p(1) * q(2) - p(2) * q(1) + p(3) * q(0)};
q(0) * p(0) - q(1) * p(1) - q(2) * p(2) - q(3) * p(3),
q(1) * p(0) + q(0) * p(1) - q(3) * p(2) + q(2) * p(3),
q(2) * p(0) + q(3) * p(1) + q(0) * p(2) - q(1) * p(3),
q(3) * p(0) - q(2) * p(1) + q(1) * p(2) + q(0) * p(3) };
}
/**