Merge pull request #11151 from jordan-woyak/quat-fix

Fix some bad quaternion math.
This commit is contained in:
Mai authored and GitHub committed 2022-10-12 17:35:50 +00:00
commit a5fa95adfd
2 files changed
+4 -2

No files matched your search

+3 -1
View File
@@ -398,7 +398,9 @@ Common::Quaternion GetRotationFromAcceleration(const Common::Vec3& accel)
Common::Quaternion GetRotationFromGyroscope(const Common::Vec3& gyro)
{
return Common::Quaternion{1, gyro.x / 2, gyro.y / 2, gyro.z / 2};
const auto length = gyro.Length();
return (length != 0) ? Common::Quaternion::Rotate(length, gyro / length) :
Common::Quaternion::Identity();
}
Common::Matrix33 GetRotationalMatrix(const Common::Vec3& angle)