User:Rschwieb/GA Discussion/Comparison of methods: rotations

=Description= The subsequent sections first describe how a rotation is represented, then describe the procedures to solve basic tasks.

Basic rotation tasks:


 * Problem A: Given two vectors, find a rotation with plane of rotation containing the vectors that turns the first vector in the direction of the second.


 * Problem B: Given two sets of vectors, one of which is known to be obtained from the other through rotation, find a rotation that carries each vector in the first set to the corresponding vector in the second set (again keeping vectors orthogonal to all those involved unchanged).


 * Problem C: in 3-D, given a plane and a specified angle of rotation, find a rotor representing the rotation.


 * Problem D: (n-D analogues of C)

Rotation matrix procedure

 * Problem A: The matrix b aT rotates a unit vector a to a unit vector b More complicated than this: matrix needs to be full rank. Without thinking very hard I suspect you may have to construct full before-and-after orthonomal basis sets A and B, then form B AT similar to Problem B, but there may be some short-cuts for the invariant subspace.
 * Problem B: see e.g Triad method for 3d case; in higher dimensions, one could use Gram-Schmidt to enforce orthogonalisation.

GA procedure
In a geometric algebra, a rotation is represented directly by an element of the algebra, called a rotor. A rotor R acts upon any element X of the algebra to produce its rotated equivalent X′:
 * $$\, X' = RXR^{-1} $$.

In 3 dimensions, this is exactly the quaternion method. (Found at Euvision Technologies: “Fontijne’s Formula” (apparently derived from GA): if 3D vector p rotates to p’, and q to q’, the quaternion of the rotation is [(q’+q)·(p’−p), (q’−q)×(p’−p)]. — Quondum☏✎ 20:34, 6 February 2012 (UTC))

It is customary (but not necessary) to normalize R, so that RR~ = 1, i.e. R−1 = R~. R is always an even multivector. Here the notation A~ (alternately A†) denotes the reversion of A.

Given two vectors a and b with a2 = b2 = ±1, the rotation that rotates a into b and keeps their orthogonal complement unchanged is:
 * Solution of Problems A and B in n-D (in 3-D this is no different):
 * $$R=\pm \frac{1+ba}{|a+b|} $$

The solution has been normalized. The distinction of sign is topologically significant. The case of (a + b)2 = 0 corresponds to no solution.
 * This rotation is associated with a plane of rotation given by b∧a. If b = −a, this is not sufficient to define a plane; there are many planes that could achieve such a rotation, but such rotations will also cause some vectors orthogonal to a and b to be transformed.

Given two sets of k vectors {ei} and {fi} related by a rotation, find a rotor R that rotates the one into the other (so that fi = ReiR−1), leaving all orthogonal vectors unchanged. Doran and Lazenby give the normalized solution for where the vectors form a 3-D basis in Euclidean space:
 * Example solution of Problem B:
 * $$\, R = \pm \frac{1 + f_j e^j}{|1 + f_i e^i|} $$,

where {ek} is the dual basis to {ek}. The case of fkek = −1 requires special care.

A solution for n-D and n independent vectors related by a rotation (not verified):
 * $$\, R = \pm \frac{1 + f_k e^k}{\sqrt{2 + 2 f_k \cdot e^k}} $$

Given a plane and an angle of rotation in n-D, give the bivector describing the rotation and how R is related to it.
 * Example 3:

Given two vectors a and b spanning the plane and with the magnitude giving angle of rotation of θ in the direction from a to b, the bivector describing the plane and angle of rotation (picture a unit vector sweeping out a pizza slice) is
 * $$\, B = \frac{\theta (a \wedge b)}{|a^2 b^2 - (a \cdot b)^2|} $$

and the rotor is
 * $$\, R = \exp (-B/2) $$.

This can be easily generalized to independent angles with respect orthogonal planes of rotation in 4-D and above: just add the bivectors.

Smooth rotation: expression of the SLERP in GA.
 * Example 4:

Quaternion procedure

 * Example "baby" solution in quaternions:

Problem: Demonstrate how to rotate the vector [0,1,1] 90 degrees about the y-axis to lie over [1,1,0] using a quaternion.


 * I am inclined to think the problem through in 3D GA, and apply the following mapping (treating quaternions (underlined) as being the even subalgebra of the GA), with the correspondence $i = −e_{2}e_{3}$, $j = −e_{3}e_{1}$, $k = −e_{1}e_{2}$; also $I = e_{1}e_{2}e_{3}$:
 * MAPPING : QUATERNION ↔ $G_{3,0}$
 * identity : quaternion scalar ↔ scalar [$a = a$]
 * dual : quaternion vector ↔ vector [$a = −aI$, $a = aI$]
 * identity : quaternion pseudovector ↔ bivector [$a = a$]
 * identity : quaternion rotor ↔ even grade versor (i.e. proper rotor) [$R = R$]
 * dual : quaternion reflection ↔ odd grade versor (i.e. improper rotor)
 * dual : quaternion pseudoscalar ↔ pseudoscalar


 * In GA, the rotor for the rotation (rotating $$ \hat{z} = e_3 $$ into $$ \hat{x} = e_1 $$ the short way around the $y$-axis; for the long way negate the rotor) is
 * $$ \underline{R} = R = {1 + e_1e_3 \over \left| e_1 + e_2 \right|} = \frac{1}{\sqrt{2}} + { j \over \sqrt{2} } $$
 * $$ a = e_2 + e_3 \qquad b = e_1 + e_2 $$
 * $$ \underline{a} = -aI = -(e_2 + e_3)e_1e_2e_3 = j+k \qquad \underline{b} = -bI = -(e_1 + e_2)e_1e_2e_3 = i+j $$
 * So working purely with quaternions,
 * $$ \underline{a} = j+k \qquad \underline{b} = i+j $$
 * $$ \underline{R} = \tfrac{1}{\sqrt{2}} + \tfrac{j}{\sqrt{2}} \qquad \underline{R}^{\dagger} = \tfrac{1}{\sqrt{2}} - \tfrac{j}{\sqrt{2}} $$
 * Checking, we find
 * $$\underline{R}\underline{a}\underline{R}^{\dagger} = (\tfrac{1}{\sqrt{2}} + \tfrac{j}{\sqrt{2}})(j+k)(\tfrac{1}{\sqrt{2}} - \tfrac{j}{\sqrt{2}}) = i+j = \underline{b}$$
 * as expected.
 * Beware the normal convention with quaternions is not the GA-centric approach I have used, though I have deliberately chosen the dual mapping for vectors to have matching signs, so it may be directly equivalent. Note that I have used the GA vectors (not underlined) rather than the corresponding quaternion vectors to calculate the rotor, though finding the expression for $$\underline{R}$$ from the quaternions $$ \hat{\underline{x}} = -\hat{x}I = i $$ etc. will be simple enough.  Feel free to trim this down to a concise version.  Also, no guarantees that this is correct.  — Quondum☏ 21:29, 28 April 2012 (UTC)