mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
quaternion: reuse existing dot product
This commit is contained in:
@@ -194,7 +194,7 @@ public:
|
|||||||
{
|
{
|
||||||
Quaternion &q = *this;
|
Quaternion &q = *this;
|
||||||
Vector3<Type> cr = src.cross(dst);
|
Vector3<Type> cr = src.cross(dst);
|
||||||
float dt = src.dot(dst);
|
const float dt = src.dot(dst);
|
||||||
/* If the two vectors are parallel, cross product is zero
|
/* If the two vectors are parallel, cross product is zero
|
||||||
* If they point opposite, the dot product is negative */
|
* If they point opposite, the dot product is negative */
|
||||||
if (cr.norm() < eps && dt < 0) {
|
if (cr.norm() < eps && dt < 0) {
|
||||||
@@ -216,7 +216,7 @@ public:
|
|||||||
cr = src.cross(cr);
|
cr = src.cross(cr);
|
||||||
} else {
|
} else {
|
||||||
/* Half-Way Quaternion Solution */
|
/* Half-Way Quaternion Solution */
|
||||||
q(0) = src.dot(dst) + sqrt(src.norm_squared() * dst.norm_squared());
|
q(0) = dt + sqrt(src.norm_squared() * dst.norm_squared());
|
||||||
}
|
}
|
||||||
q(1) = cr(0);
|
q(1) = cr(0);
|
||||||
q(2) = cr(1);
|
q(2) = cr(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user