Skip to content

Commit

Permalink
WiimoteEmu: Fix gyroscope/quaternion conversion math.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-woyak committed Oct 11, 2022
1 parent 6eb1f8b commit bf53e14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bf53e14

Please sign in to comment.