MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / computeNormalizedAngle

Method computeNormalizedAngle

src/systems/SolveHingeJointSystem.cpp:719–734  ·  view source on GitHub ↗

Given an angle in radian, this method returns the corresponding angle in the range [-pi; pi]

Source from the content-addressed store, hash-verified

717
718// Given an angle in radian, this method returns the corresponding angle in the range [-pi; pi]
719decimal SolveHingeJointSystem::computeNormalizedAngle(decimal angle) const {
720
721 // Convert it into the range [-2*pi; 2*pi]
722 angle = std::fmod(angle, PI_TIMES_2);
723
724 // Convert it into the range [-pi; pi]
725 if (angle < -PI_RP3D) {
726 return angle + PI_TIMES_2;
727 }
728 else if (angle > PI_RP3D) {
729 return angle - PI_TIMES_2;
730 }
731 else {
732 return angle;
733 }
734}
735
736// Given an "inputAngle" in the range [-pi, pi], this method returns an
737// angle (modulo 2*pi) in the range [-2*pi; 2*pi] that is closest to one of the

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected