Reputation: 3364
I have some initial rotation r0
represented by quaternion and some actual rotation r
(also an quaternion). I would like to get the quaternion that represents the delta of rotation.
E.g. if r0
stands for 30st OX
rotation and r
is 50st OX
, the rDelta
should contain quaternion that represents 20st OX
rotation.
How to compute the rDelta
?
My guess is either:
rDelta = r0.getConjugated() * r
or
rDelta = r.getConjugated() * r0
? But maybe none of those.
Upvotes: 2
Views: 3873
Reputation: 1649
I might be wrong, but if I remember correctly, assuming you're in Unity and applying Q's in Right-to-Left order (because it's left-handed?), then in order to get "from" Q1 "to" Q2, you first inverse Q1, then apply Q2 to the result of that, and that gives you the delta. How much you need to rotate from Q1, to get to Q2..
Quaternion r0 = Quaternion.Euler(10, 0, 0);
Quaternion r = Quaternion.Euler(20, 0, 0);
Quaternion rDelta = r * Quaternion.Inverse(r0);
Heck, I don't even know what a quaternion conjugate is! I think for homogenous matrices, they're the same as the inverse? Yep, just looked that up.
This is answered here too: https://gamedev.stackexchange.com/questions/143430/relative-quaternion-rotation-delta-rotation-produces-unstable-results
Upvotes: 1
Reputation: 1908
It depends , how your rDelta will be applied (from right or left)
1 )r = r0 * rDelta; r = r0 * conj(r0) * r; rDelta == conj(r0) * r;
2 )r = rDelta * r0; r = r * conj(r0) * r0; rDelta == r * conj(r0);
Upvotes: 1
Reputation: 4283
so you want to find rx
where rx * r0 == r1
?
rx * r0 * conj(r0) == r1 * conj(r0)
rx == r1 * conj(r0)
All you need to know is that a rotation around q = q2 * q1
is equivalent to a rotation first around q1
and then q2
. If you want to go from an initial rotation r0
to the final rotation r1
you simply substitute: r1 = rx * r0
where rx
is the missing step between r0
and r1
.
Upvotes: 2
Reputation: 9382
Your quaternion q(R2/R1)
represent the rotation of R2 w.r.t. R1
Your quaternion q(R3/R1)
represent the rotation of R3 w.r.t. R1
You wish to have the rotation of R3 w.r.t. R2
That is q(R3/R2) = q(R3/R1) * q(R1/R2) = q(R3/R1) * conjugate(q(R2/R1))
where * is the product of quaternion
Upvotes: 0