- Home /
Remainder of two rotations
I thought about this and the best way I could think of asking it is.
How do you find the remainder of two rotations?
In essence I am trying rotate an object back to zero without setting its rotation to zero.
Answer by Eno-Khaon · Feb 18, 2016 at 03:58 AM
Calculating the inverse of a Quaternion is done using, well, Quaternion.Inverse().
The result will return the rotation required to return from a rotation to Quaternion.identity.
By association, this also means that getting a rotation relative to another is done by multiplying the inverse of a rotation by a destination offset rotation:
// Create offset. This is the rotation to go from A to B.
Quaternion offsetAtoB = Quaternion.Inverse(A) * B;
// Use offset. From a new baseline, multiply by the offset.
Quaternion offsetRotation = transform.rotation * offsetAtoB;
Your answer
Follow this Question
Related Questions
Rotation Complications + rotation with parents and children? 1 Answer
Rotating 2D sprite to match surface. 0 Answers
align to floor in local X 2 Answers
Inverse of Quaternion.eulerAngles? 0 Answers