I'm trying to unrotateun-rotate a quaternion, aligning it with the axis, and then rotate it back to where it was originally. But with every iteration it seems to lose precision and just after 20 iterations the rotation dissapearsdisappears. Here is an example, which is a simplification of my code:
Quaternion rotation = Quaternion.Euler (0f, 90f, 0f);
Debug.Log ("Before: " + rotation.ToString ("F7") + " / Euler: " +
rotation.eulerAngles.ToString());
int iterations = 1;
for (int i = 0; i < iterations; i++) {
var currentRotation = rotation;
rotation = Quaternion.Inverse (currentRotation) * rotation;
rotation = currentRotation * rotation;
}
Debug.Log ("After: " + rotation.ToString ("F7") + " / Euler: " +
rotation.eulerAngles.ToString());