Quaternion library cleanups and code style

This commit is contained in:
Oleg Kalachev 2023-12-13 08:42:03 +03:00
parent 997af183f0
commit d3e715ae53

View File

@ -69,22 +69,6 @@ public:
return ret; return ret;
} }
static Quaternion _fromBetweenVectors(float a, float b, float c, float x, float y, float z)
{
float dot = a * x + b * y + c * z;
float w1 = b * z - c * y;
float w2 = c * x - a * z;
float w3 = a * y - b * x;
Quaternion ret(
dot + sqrt(dot * dot + w1 * w1 + w2 * w2 + w3 * w3),
w1,
w2,
w3);
ret.normalize();
return ret;
};
void toAxisAngle(float& a, float& b, float& c, float& angle) void toAxisAngle(float& a, float& b, float& c, float& angle)
{ {
angle = acos(w) * 2; angle = acos(w) * 2;
@ -129,12 +113,7 @@ public:
(*this) = Quaternion::fromEulerZYX(euler.x, euler.y, yaw); (*this) = Quaternion::fromEulerZYX(euler.x, euler.y, yaw);
} }
void toAngularRates(float& x, float& y, float& z) Quaternion& operator *= (const Quaternion& q)
{
// this->toAxisAngle(); // TODO:
}
Quaternion & operator*=(const Quaternion &q)
{ {
Quaternion ret( Quaternion ret(
w * q.w - x * q.x - y * q.y - z * q.z, w * q.w - x * q.x - y * q.y - z * q.z,
@ -144,7 +123,7 @@ public:
return (*this = ret); return (*this = ret);
} }
Quaternion operator*(const Quaternion& q) Quaternion operator * (const Quaternion& q)
{ {
return Quaternion( return Quaternion(
w * q.w - x * q.x - y * q.y - z * q.z, w * q.w - x * q.x - y * q.y - z * q.z,