From 544692f96a09c1a76ff259bc1b5e91e9fef57bc4 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Thu, 22 Oct 2020 22:48:22 -0500 Subject: Common: add convenience function to convert a Quaternion to a Matrix44 --- Source/Core/Common/Matrix.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Source/Core/Common/Matrix.cpp') diff --git a/Source/Core/Common/Matrix.cpp b/Source/Core/Common/Matrix.cpp index 48adcba274..421dda28f5 100644 --- a/Source/Core/Common/Matrix.cpp +++ b/Source/Core/Common/Matrix.cpp @@ -269,6 +269,11 @@ Matrix44 Matrix44::FromMatrix33(const Matrix33& m33) return mtx; } +Matrix44 Matrix44::FromQuaternion(const Quaternion& q) +{ + return FromMatrix33(Matrix33::FromQuaternion(q)); +} + Matrix44 Matrix44::FromArray(const std::array& arr) { Matrix44 mtx; -- cgit v1.2.3 From d35287b6e49fe265729d1d8a83630cb4ff7e6367 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 26 Dec 2020 23:08:40 -0600 Subject: Common: update Quaternion to allow rotating pitch, yaw, and roll all at once --- Source/Core/Common/Matrix.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Source/Core/Common/Matrix.cpp') diff --git a/Source/Core/Common/Matrix.cpp b/Source/Core/Common/Matrix.cpp index 421dda28f5..9f5ff40cb3 100644 --- a/Source/Core/Common/Matrix.cpp +++ b/Source/Core/Common/Matrix.cpp @@ -56,6 +56,13 @@ Quaternion Quaternion::RotateZ(float rad) 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) { const auto sin_angle_2 = std::sin(rad / 2); -- cgit v1.2.3