1

I'm trying to represent coordinate systems (and transformations between them) in arbitrary dimensions. A coordinate system can be described by its pose (position + orientation) and I am unsure how to best represent its orientation in arbitrary dimensions.

Based on my search, it should be possible to represent an arbitrary pose as a sequence of rotations (source). Further, it should be possible to represent an arbitrary rotation by an angle (amount to rotate), and a plane in which to rotate (source). This means I should be able to do something like this in code

from dataclasses import dataclass
from typing import List
from numpy.typing import ArrayLike


@dataclass
class Rotation:
    # amount to rotate
    alpha: float
    # two vectors spanning the plane
    u: ArrayLike
    v: ArrayLike

@dataclass
class Orientation:
    orientation: List[Rotation]

This seems quite naive and inefficient. Each rotation has to be applied one at a time, which may not be very efficient computationally speaking. It is also non-unique. For example, these three objects represent the same orientation

Orientation(Rotation(np.pi, (0, 1), (1, 0)))
Orientation(Rotation(-np.pi, (1, 0), (0, 1)))
Orientation([Rotation(np.pi, (0, 1), (1, 0)), Rotation(0.42, (0, 1), (1, 0)), Rotation(-0.42, (0, 1), (1, 0))])

How can I improve this and what is the best data structure to use here?

EternalObserver
  • 517
  • 7
  • 19
FirefoxMetzger
  • 2,880
  • 1
  • 18
  • 32
  • see https://stackoverflow.com/a/45116079/2521214 for ND use (N+1) x (N+1) [homogenuous transform matrix](https://stackoverflow.com/a/28084380/2521214). – Spektre Jun 12 '21 at 07:16

1 Answers1

2

Rotation matrices can represent rotations in arbitrary N dimensions.

It is possible to compose rotation matrices using the matrix product. So you'd need only to store a single matrix to represent an orientation, even if it's constructed from multiple individual rotations.

While a single plane/angle representation is more memory efficient than a full matrix, one matrix can represent the combination of multiple plane/angle rotations. Also, applying a matrix transformation is very efficient - just a couple of dot products.

In 3D space it's often beneficial to represent rotations as quaternions, but I don't think they can be generalized to arbitrary dimensionality. Although they can be generalized to ND space, this is is not very intuitive1.


1Thank you, Spektre, for the clarifying comment.

MB-F
  • 22,770
  • 4
  • 61
  • 116
  • Quaternions will indeed not work well in spaces other than 3D. In 4D you need a pair of two quaternions to uniquely represent a rotation. This (ofc) doesn't hold in 6D and so forth. The math on how to do this properly exists (some buzzwords are Clifford-Algebra, Rotors, k-vectors), but I am not well-versed enough in geometric algebra to work it out myself x) – FirefoxMetzger May 19 '21 at 13:40
  • [quaternions generalized to ND are possible](https://stackoverflow.com/a/49031090/2521214) however not intuitive just like in 3D ... transform matrices are way better ... – Spektre Jun 12 '21 at 07:18