WiimoteEmu: Use quaternions for orientation.

This commit is contained in:
Jordan Woyak 2020-10-19 16:34:00 -05:00
parent 09431635f3
commit 907fdd26fc
2 changed files with 7 additions and 6 deletions

View File

@ -734,10 +734,10 @@ Common::Matrix44 Wiimote::GetTransformation(const Common::Matrix33& extra_rotati
Common::Matrix44::Translate(-m_swing_state.position - m_point_state.position);
}
Common::Matrix33 Wiimote::GetOrientation() const
Common::Quaternion Wiimote::GetOrientation() const
{
return Common::Matrix33::RotateZ(float(MathUtil::TAU / -4 * IsSideways())) *
Common::Matrix33::RotateX(float(MathUtil::TAU / 4 * IsUpright()));
return Common::Quaternion::RotateZ(float(MathUtil::TAU / -4 * IsSideways())) *
Common::Quaternion::RotateX(float(MathUtil::TAU / 4 * IsUpright()));
}
Common::Vec3 Wiimote::GetTotalAcceleration() const
@ -758,8 +758,9 @@ Common::Vec3 Wiimote::GetTotalAngularVelocity() const
Common::Matrix44 Wiimote::GetTotalTransformation() const
{
return GetTransformation(Common::Matrix33::FromQuaternion(m_imu_cursor_state.rotation) *
Common::Matrix33::RotateX(m_imu_cursor_state.recentered_pitch));
return GetTransformation(Common::Matrix33::FromQuaternion(
m_imu_cursor_state.rotation *
Common::Quaternion::RotateX(m_imu_cursor_state.recentered_pitch)));
}
} // namespace WiimoteEmu

View File

@ -162,7 +162,7 @@ private:
GetTransformation(const Common::Matrix33& extra_rotation = Common::Matrix33::Identity()) const;
// Returns the world rotation from the effects of sideways/upright settings.
Common::Matrix33 GetOrientation() const;
Common::Quaternion GetOrientation() const;
Common::Vec3 GetTotalAcceleration() const;
Common::Vec3 GetTotalAngularVelocity() const;