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.
71 float angleX = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.x);
72 angleX = Mathf.Clamp(angleX, -minbounds.x, maxbounds.x);
73 q.x = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleX);
75 float angleY = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.y);
76 angleY = Mathf.Clamp(angleY, -minbounds.y, maxbounds.y);
77 q.y = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleY);
79 float angleZ = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.z);
80 angleZ = Mathf.Clamp(angleZ, -minbounds.z, maxbounds.z);
81 q.z = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleZ);