5
$\begingroup$

I have been working with 3D rotations for some time now, wth my preferred implementation being realised using unit quaternions - especially from a computational efficiency point of view by avoiding any trigonomtric operations (the target is typically a resource-constrained microcontroller, sometimes without an FPU).

I now have a problem where I need to operate only in 2D space, rotating by a single angle (or, more correctly, successive single rotations, and using the ersult to rotate vectors). Of course, I have the option of ordinary complex numbers, or a reduced quaternion set, keeping two of the complex terms at zero.

I'm guessing this isn't the first time someone has needed to tackle this problem. So my questions are:

  • What would be the analog to unit quaternions in 2D space? Does it have a name, and does it have similar properies to unit quaternions in 3D space? Is this simply a a "reduced set" of unit quaternions being a complex number with the angle encoded as $z = \cos(\theta/2) + j \sin(\theta/2)$?
  • What are the advantages and disadvantages - especially from a numerical error and computational efficincy point of view - of using this represenation vs a standard complex number represenation, i.e. $z = \cos(\theta) + j \sin(\theta)$?
  • Or, am I better off with a different rotation represenation altogether, given the goals stated above?

Bonus question: I'm guessing this is part of a more general field of mathematics. What should I be looking at to find out more?

$\endgroup$
  • $\begingroup$ Considering performance and precision, etc. is your issue, I would ask this question in the game programming section. $\endgroup$ – nilo de roock Oct 7 '15 at 23:11
  • $\begingroup$ The simpler representation is going to be faster and more accurate. $\endgroup$ – jkabrg Oct 7 '15 at 23:16
  • $\begingroup$ @ndroock1, I ask here because the mathematics community generally have a better understanding of error analysis and the underlying rotation theory. I would actually go to scicomp.stackexchange.com before I went to the gaming community, but there are fewer specialists in rotation there than here. $\endgroup$ – Damien Oct 7 '15 at 23:16
  • $\begingroup$ @NaN, the simplest represenation is simply going to be $\theta$, which is fast for accumulating angles, but slow for rotating vectors as $\sin\theta$ and $\cos\theta$ need to be constructed. $\endgroup$ – Damien Oct 7 '15 at 23:19
  • $\begingroup$ @Damien I'm referring to $\cos\theta + j\sin\theta$ $\endgroup$ – jkabrg Oct 7 '15 at 23:20
2
$\begingroup$

Quaternions with the restriction that you can only use a single rotation plane work just fine still. They would take the form

$$q = \cos \frac{\theta}{2} + v \sin \frac{\theta}{2}$$

for some unit quaternion $v$.

When we restrict ourselves to a single rotation plane, that means we consider rotating vectors (pure imaginary quaternions) that are perpendicular to the rotation axis (described by $v$).

It is not difficult to show that, for any vector $a \perp v$,

$$\exp(v \theta/2) a \exp(-v \theta/2) = \exp(v\theta) a = a \exp(-v \theta)$$

This is why complex rotations don't usually use the double-sided form that rotations in 3d use: it's simply unnecessary.

From a programming standpoint, the double-sided form requires more floating point operations; this is strictly unnecessary in 2d.

Of course, only the double-sided form of rotation generalizes beyond 3d.

With all this in mind, I think you can consider using quaternions with some terms zeroed out, but notice that when translating quaternions to 2d, the rotation axis is perpendicular to the vectors being rotated. This means you can't zero out particular components regardless of whether they're vectors being rotated or quaternions being used to rotate them.

Furthermore, I think the matter of ensuring some terms remain identically zero could be an issue. You might be better off converting to complex and then converting back when you're done.

$\endgroup$
-1
$\begingroup$

What would be the analog to unit quaternions in 2D space?

These are the complex numbers.

What are the advantages and disadvantages of using this represenation vs a standard complex number represenation

If you compose rotations then you have to work in double not to loose precision.

$\endgroup$
  • $\begingroup$ before you downvote please read $\endgroup$ – user48672 Nov 8 '17 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.