5
$\begingroup$

Suppose I've got two quaternions that each represent an angle. I need to interpolate between these two angles (from 0% to one side to 100% to another side).

Since I work a lot with complex numbers, I'd thought about getting the "arg" of these quaternions, averaging them, and creating a new quaternion. But then I don't think quaternions have "args" or anything like that..

How does one go around getting an interpolation between two quaternions?

I come from a computer programming background, so all I have is a quaternion class I "inherited" from some tutorial on the web somewhere.

$\endgroup$
2
  • $\begingroup$ using $q=\cos(\alpha/2)+u\sin(\alpha/2)$ with $u=ai+bj+ck$ a unit quaternion with real part zero you can read off the angle $q$ represents (here $q$ rotates by the angle $\alpha$ about $u$ (identifying $\mathbb{R}^3$ with the pure quaternions) via conjugation, $v\mapsto qvq^{-1}$). $\endgroup$
    – yoyo
    Commented Apr 3, 2011 at 20:57
  • $\begingroup$ Related (newer) question math.stackexchange.com/q/686901/115115 $\endgroup$ Commented Jun 12, 2014 at 13:50

2 Answers 2

6
$\begingroup$

Usually (unit) quaternions represent rotations in 3D. Is that what you mean when you say they "represent an angle"? If you have two (unit) quaternions that each represent a rotation, they're both represented by unit vectors on the hypersphere. There are basically two ways to interpolate between them, a simpler way and a more complicated way that might have preferable properties, depending on what you need this for.

The simpler way is to take convex combinations of the two unit vectors ($\lambda$ times one and $1-\lambda$ times the other, with $\lambda\in[0,1]$) and then normalize them to obtain a unit vector again.

The more complicated way is to find the 4D rotation that rotates the plane they lie in (e.g. by orthogonalizing one of them against the other) and then rotate by some fraction of the angle you need to rotate one into the other.

Both methods yield the same set of interpolation results, but with different parameterizations (the second method yielding a "smoother" and "more natural" parametrization).

Either way, in case your quaternions represent rotations about the same axis through different angles, the interpolated quaternions will also represent rotations about that same axis, through angles in between.

$\endgroup$
1
  • $\begingroup$ Ah, true, could always interpolate them just by adding them like that (the first way). Since it seems to be the simpler way, I think I'll try that first. Thanks! $\endgroup$
    – kamziro
    Commented Apr 4, 2011 at 5:18
0
$\begingroup$

Unfortunately when you go from complex to quaternions, you no longer have a single angle about the origin to deal with, you have the equivalent of four angles / four degrees of freedom (three degrees of freedom for the rotation axis, and one degree of freedom for the rotation about that axis) -- so your trick for complex numbers won't work for the quaternions.

The correct way to interpolate between two quaternions is to use slerp. Incidentally this works for both interpolation (where the blending factor alpha is between 0 and 1) and extrapolation (where the blending factor is less than 0 or greater than 1). It's the spherical (rotational) equivalent of linear interpolation between two vectors.

$\endgroup$
4
  • $\begingroup$ What makes you say three angles / degrees of freedom for 4D rotations? $\endgroup$
    – anon
    Commented Sep 4, 2020 at 10:05
  • $\begingroup$ @runway44 I was talking only about the rotation axis -- when you move from 2D to 3D, a rotation axis has three dimensions. That means that you can't just take a difference in angle about the origin (in the case of complex numbers) or even the difference in angle about the rotation axis (in the case of 3D rotations), you have to also rotate one axis to align with the other. Slerp accomplishes both of these tasks. $\endgroup$ Commented Sep 4, 2020 at 23:39
  • $\begingroup$ I don't think you're describing the 3D situation very well, but I agree there are 3 degrees of freedom in specifying a 3D rotation. However your answer says "when you go from 2D to 4D" but in fact there are 6 degrees of freedom in specifying a 4D rotation! $\endgroup$
    – anon
    Commented Sep 5, 2020 at 5:58
  • $\begingroup$ Clearly since I compared 2D to complex and 4D to quaternions, I'm talking about a 3-dimensional rotation in the quaternion case, not a 4-dimensional rotation. But I'll drop the 2D and 4D terms, since I agree the terminology is confusing. $\endgroup$ Commented Sep 5, 2020 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .