mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 06:07:36 +08:00
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:
committed by
Julian Kent
parent
d613055462
commit
2bee0d078c
@@ -252,14 +252,14 @@ public:
|
|||||||
* @param q quaternion to multiply with
|
* @param q quaternion to multiply with
|
||||||
* @return product
|
* @return product
|
||||||
*/
|
*/
|
||||||
Quaternion operator*(const Quaternion &q) const
|
Quaternion operator*(const Quaternion &p) const
|
||||||
{
|
{
|
||||||
const Quaternion &p = *this;
|
const Quaternion &q = *this;
|
||||||
return {
|
return {
|
||||||
p(0) * q(0) - p(1) * q(1) - p(2) * q(2) - p(3) * q(3),
|
q(0) * p(0) - q(1) * p(1) - q(2) * p(2) - q(3) * p(3),
|
||||||
p(0) * q(1) + p(1) * q(0) + p(2) * q(3) - p(3) * q(2),
|
q(1) * p(0) + q(0) * p(1) - q(3) * p(2) + q(2) * p(3),
|
||||||
p(0) * q(2) - p(1) * q(3) + p(2) * q(0) + p(3) * q(1),
|
q(2) * p(0) + q(3) * p(1) + q(0) * p(2) - q(1) * p(3),
|
||||||
p(0) * q(3) + p(1) * q(2) - p(2) * q(1) + p(3) * q(0)};
|
q(3) * p(0) - q(2) * p(1) + q(1) * p(2) + q(0) * p(3) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user