1
0
forked from josh/j3ml

Adding code x3

This commit is contained in:
2023-12-28 16:04:31 -06:00
parent 24cc2e79bc
commit 7e32c2ec62
10 changed files with 71 additions and 27 deletions

View File

@@ -135,11 +135,34 @@ namespace LinearAlgebra {
y*reciprocalSinAngle,
z*reciprocalSinAngle
};
return {axis, angle};
return AxisAngle(axis, angle);
}
float Quaternion::AngleBetween(const Quaternion &target) const {
Quaternion delta = target / *this;
return delta.Normalize().Angle();
}
Quaternion Quaternion::operator/(const Quaternion &rhs) const {
return {
x*rhs.w - y*rhs.z + z*rhs.y - w*rhs.x,
x*rhs.z + y*rhs.w - z*rhs.x - w*rhs.y,
-x*rhs.y + y*rhs.x + z*rhs.w - w*rhs.z,
x*rhs.x + y*rhs.y + z*rhs.z + w*rhs.w
};
}
Matrix3x3 Quaternion::ToMatrix3x3() const {
return {
1 - 2 *(y*y) - 2*(z*z), 2*x*y - 2*z*w, 2*x*z + 2*y*w,
2*x*y + 2*z*w, 1-2*x*x - 2*z*z, 2*y*z - 2*x*w,
2*x*z - 2*y*w, 2*y*z + 2*x*w, 1-2*x*x - 2*y*y
};
}
Quaternion Quaternion::operator+(const Quaternion &rhs) const {
return {
x + rhs.x, y + rhs.y, z + rhs.z,w + rhs.w
};
}
}