This is a mess gather of notes on quats from emails -
=============================================================
More notes -
the exponential map gets very good around the identity rotation. This should be
obvious, because the exponential map takes you to the "Lie algebra" of
the space. The Lie algebra generates infinitesimal rotations, so it should
be perfect around the identity. It gets worse and worse for more macroscopic
rotations.
You can think of this in another nice way. The sphere S3 is a manifold.
Any manifold can be *locally* covered with a euclidean space, R3. S3 of
course cannot be globally covered with R3. So, you can take any point "q"
on S3 (q is a quat) and construct a mapping from S3 to R3 :
M_q : S3->R3
Such that
M_q(p)
is a non-distorting map when p is very near "q". In fact, this map just
consists of finding the local perpendiculars to "q" and using them as basis
vectors for the Euclidean space R3.
In the case of the exponential map, "q" is chosen to be the identity, but
you can define an arbitrary map S3<->R3 which is very good for any one
point you desire.
To be more specific about the Lie algebra of quats :
Q = cos(theta/2) + sin(theta/2) * ( nx I + ny J + nz K )
where "n" is a normal vector, and I,J,K are the rotations by Pi around x,y, and z.
Then
Q = e^{ (theta/2) * ( nx I + ny J + nz K ) }
We see that the basis vectors for the R3 space of the exponential map are just
the quaternion-space base rotations, I,J and K.
Note that when theta is very small, the quat is very nearly :
Q = 1 + (theta/2) * ( nx I + ny J + nz K )
which is just
Q = 1 + log(Q)
which shows that the exp-map is very good around the identity quat.
=============================================================
Hmm.. I must be missing something here. In the exponential map, the points
pi * n and -pi * n produce the same rotation. So if you think of it as a disc,
opposing points on the perimeter of the disc represent the same rotation.
In general a rotation by "angle" and a rotation by "2pi - angle"
To interpolate between e1 and e2, you can either interpolate directly, or
interpolate by crossing the disk boundary. There's never a reason to cross
the disk boundary more than once. So, you can just consider the direct path
from e1 to e2 and the direct path from e1 to (2pi - angle2) * -n2
If e1 = l1 * n1 and e2 = l2 * n2 (length and normal)
Then these two distances are equal (in Euclidean space in the exponential map)
when
l1 * (n1 * n2) = l2 - pi
here l1 and l2 are both in [0,pi]
This has no solution unless (n1 * n2) is negative. I naively suggested originally
that you should flip whenever (n1*n2) is negative, but that's obviously not true;
for example if l1 and l2 are very short, this will again have no solution. In fact,
(n1 * n2) <= 0
(l1 + l2) >= pi
are both required for a solution.
=============================================================
> you really need to read the "Rational Map" paper and related papers,
> like "The Most Natural Map of a Sphere". These guys discuss arbitrary
> mappings from S3<->R4 and argue that the "rational map" is the most
> "natural". See this:
=============================================================
Well, quats do have this numerical problem, that the axis of rotation becomes
very poorly conditioned when the amount of rotation becomes very small.
For example, if you have separate {axis,angle} representation, then lerping
between
{Y axis, pi/4} and {Y axis, -pi/4}
is totally robust, even around t=0.5 (nearly zero rotation).
For something like Quats or the exponential map, you go near zero, and the
axis becomes errorful. There's no problem making rotation matrices, but if
you actually need the "axis" for something, it gets ugly. I'm not suggesting
that axis-angle is a good rep for interpolating, but it can be handy for some
applications.
At 10:33 AM 7/25/2002 -0700, Casey Muratori wrote:
> I was completely out to lunch on the Lerp thing (unless a quat is negative),
> but I think that a slerp might could be +Y or -Y.
I think luncheon might still be on. Lerp and Slerp always pick the same
trajectory - so they're essentially equivalent. It's just that the
interpolation speed is not constant on a lerp, whereas it is on a slerp.
With both methods, you always pre-condition so that they're in the same
hemi-hypersphere, or hyper-hemisphere, depending on your choice of
hyphenation.
> If you have (pi/4 + epsilon) your trajectory is not ergonomically optimal.
Well if you specifically _don't_ want the shortest path rotation, then
just don't precondition and use the full 720 degree rotation. Then
neither will ever pick the "bad" rotation you're alluding to, which is the
rotate around the back like some kind of fucked up Excorcist baby
rotation, because remember that quaternions use half-angles, so "pi/4 +
epsilon" does not look qualitatively any different than pi/4 itself.
So, you kind of get the best of both worlds this way - if you want
shortest-path, do the dot-product pre-conditioner. If you don't, then
don't, and it will remember the winding.
- Casey
=============================================================
I pointed this out to Casey & Jon a while ago, but I'll try to
rephrase it again :
basically, if you're doing splines, there's no point to using
fancier interpolators. The reason is that by appropriate choice
of your spline knots, you can approximate any interpolator to
arbitrary accuracy, so "Squad" is basically just silly.
To be more precise :
Imagine I'm doing Casey-style cubic splines of plain-lerped
quats. That is, I have some cubic-spline knots with times,
and I just lerp them and renormalize them.
Now note that I can make any cubic function with only 4 knots
of a cubic spline. That is, any cubic polynomial , f(t)
can be exactly represented with 4 knots on a cubic spline.
Now, you can approximate any interpolator using a polynomial
remapper of the "time" ; that is :
approximate Slerp(q0,q1,t) with LerpAndNormalize(q0,q1,f(t))
find the cubic f(t) that minimizes the difference; then you can
exactly represent this
LerpAndNormalize(q0,q1,f(t))
with
CubicSplineAndNormalize(4 knots,t)
for some 4 knots.
The conclusion is that by doing a cubic spline of quats using
any lerper (the simplest lerper is LerpAndNormalize, so use that),
you can do *at least* as well as a cubic-time-adjustment
approximation of slerps. The conclusion for me is that fancy
interpolators are worthless if all you're doing is playing back
a sequence of keys, since you can always approximate them with
simpler lerpers and more knots.
Fancy lerpers still may be worth while when blending anims, because
you might blend arbitrary quats that you have no prior knowledge of.
=============================================================