Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use 4d rotors

I'm trying to create a 4D environment, similar to Miegakure's.

I'm having trouble understanding how to represent rotations. The creator of Miegakure wrote this small article explaining he made a class for 4d rotors. http://marctenbosch.com/news/2011/05/4d-rotations-and-the-4d-equivalent-of-quaternions/

How can I implement the functions of this class ? In particular the functions to rotate vectors and other rotors, and getting the inverse ?

I would appreciate some pseudocode examples. Thanks a lot to anyone who bothers answering.

like image 234
Azorlogh Avatar asked Jan 03 '23 18:01

Azorlogh


1 Answers

The most common way to represent goemetric algebra multivectors (including rotors) in a computer is via an array of coefficients, one for each canonical form algebra basis element (canonical basis blade) ie. for a 4D basis space you will have a 2^4 dimensional algebra and have 2^4 dimensional array of coefficients. An alternate but probably faster way to represent them is with a dynamically resizing list with each element containing an index to a blade and the coefficient of the associated blade. In this case the multiplication of two multivectors will only use non zero basis blades and so should be algorithmically cheaper and lighter on memory usage.

In terms of practical usage I found the easiest place to get started with playing around with geometric algebra is probably in python with https://github.com/pygae/clifford . Full disclaimer I use this library daily and contribute to it extensively. This library uses the flat array of coefficients approach. With this python library you can apply 4D rotors via the sandwich product and do reversion (inversion of a rotor) via the tilde operator:

# Create a 4D geometric algebra with euclidean metric
from clifford.g4 import *

# Create a rotor
R = layout.randomRotor()

# Create a vector to rotate
V = layout.randomV()

# Apply the rotor to the vector
V2 = R*V*~R

The specific definition of the geometric product and reverse for multivectors from an N-dimensional geometric algebra can be found in Chapter 4 of Geometric algebra for Physicists by Chris Doran and Anthony Lasenby.

A good C++ GA reference implementation for N-dimensional GAs using the list of elements approach can be found in Leo Dorst's book Geometric Algebra for Physicists or on his website: http://www.geometricalgebra.net/code.html . In general this is a great resource for GA, especially the conformal model and numerical implementations and concerns.

like image 82
Hugo Hadfield Avatar answered Jan 29 '23 12:01

Hugo Hadfield