Common: update Quaternion to allow rotating pitch, yaw, and roll all at once
This commit is contained in:
parent
544692f96a
commit
d35287b6e4
|
@ -56,6 +56,13 @@ Quaternion Quaternion::RotateZ(float rad)
|
||||||
return Rotate(rad, Vec3(0, 0, 1));
|
return Rotate(rad, Vec3(0, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Quaternion Quaternion::RotateXYZ(const Vec3& rads)
|
||||||
|
{
|
||||||
|
const auto length = rads.Length();
|
||||||
|
return length ? Common::Quaternion::Rotate(length, rads / length) :
|
||||||
|
Common::Quaternion::Identity();
|
||||||
|
}
|
||||||
|
|
||||||
Quaternion Quaternion::Rotate(float rad, const Vec3& axis)
|
Quaternion Quaternion::Rotate(float rad, const Vec3& axis)
|
||||||
{
|
{
|
||||||
const auto sin_angle_2 = std::sin(rad / 2);
|
const auto sin_angle_2 = std::sin(rad / 2);
|
||||||
|
|
|
@ -337,6 +337,10 @@ public:
|
||||||
static Quaternion RotateY(float rad);
|
static Quaternion RotateY(float rad);
|
||||||
static Quaternion RotateZ(float rad);
|
static Quaternion RotateZ(float rad);
|
||||||
|
|
||||||
|
// Returns a quaternion with rotations about each axis simulatenously (e.g processing gyroscope
|
||||||
|
// input)
|
||||||
|
static Quaternion RotateXYZ(const Vec3& rads);
|
||||||
|
|
||||||
static Quaternion Rotate(float rad, const Vec3& axis);
|
static Quaternion Rotate(float rad, const Vec3& axis);
|
||||||
|
|
||||||
Quaternion() = default;
|
Quaternion() = default;
|
||||||
|
|
Loading…
Reference in New Issue