Clamps the rotation to a quaternion to the given euler-angle bounds. Eg ClampQuaternionRotation(q, new Vector3(30, 0, 120)) will clamp q to a min/max rotation of +/- 30 deg around the x Axis etc.
42 float angleX = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.x);
43 angleX = Mathf.Clamp(angleX, -bounds.x, bounds.x);
44 q.x = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleX);
46 float angleY = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.y);
47 angleY = Mathf.Clamp(angleY, -bounds.y, bounds.y);
48 q.y = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleY);
50 float angleZ = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.z);
51 angleZ = Mathf.Clamp(angleZ, -bounds.z, bounds.z);
52 q.z = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleZ);