Quaternion Rotation relative to world

Viewed 5862

Unity3D offers the following method:

Rotate(eulerAngles: Vector3, relativeTo: Space = Space.Self);

For example, this will rotate the object around it's local X axis:

transform.Rotate(Vector3(50,0,0) * Time.deltaTime, Space.Local);

If I first rotate 90 degrees around it's local y axis (which is up in unity) and then rotate it around the X axis relative to World, it will basically rotate around the local Z axis, ie:

//setup
transform.Rotate(Vector3(0, 90, 0));
//on update
transform.Rotate(Vector3(50,0,0) * Time.deltaTime, Space.World);

In my own implementation, using quaternions, I have the local rotation implemented, which was easy.

//rotate around local axis
currentRotation *= rotateQuat;

How would I go about implementing the relative to world behaviour using quaternions?

1 Answers
Related