0

I have an avatar whose body parts are rotated by using Quaternions which come from IMU sensors. The the axes of the sensor and the GameObjects of the body parts are aligned and the movementin general works. I only have problems introducing angular limits matching the human anatomy. E.g. i want to restrickt the movement of the forearm along the x-axis to a range of +-90 degrees starting froma reference pose. The problem is that the reading Euler Angles from quaternions is not deterministic. Hence it is in my eyes not possible to read Euler angles from the input Quaternions manipulate the x value and transform the euler angles back to quaternions.

My naive approach looks simplified like:

Quaternion referencePoseLocal;
Quaternion targetPoseLocal; 

if ((targetPoseLocal.eulerAngles.x - referencePoseLocal.eulerAngles.x) >90)
{targetPoseLocal.eulerAngles.x = referencePoseLocal.eulerAngles.x + 90 }
else if ((targetPoseLocal.eulerAngles.x - referencePoseLocal.eulerAngles.x) < -90)
{targetPoseLocal.eulerAngles.x = referencePoseLocal.eulerAngles.x - 90 }

transform.localRotation = Quaternion.Slerp(transform.localRotation,  referencePoseLocal*targetPoseLocal, Time.deltaTime * 10f);

In a different approach using Quaternion.Angle the angle is consistent but not broken down to the x-axis of the game opject.

How can i deal with that Problem?

0 Answers0