What is the math required to do 4d rotations?

103 Views Asked by At

I recently wondered how I could calculate 4d rotations. I know that matrices and quaternions could be used to do so, but I haven't really found anything clear and specific about what I want.

Basically, I'd like to get from the coordinates of a point $(x,y,z,w)$, to the coordinates of that point, rotated by an angle $θ$, by the desired plane of rotation. ($xy, xz, xw, yz, yw$ or $zw$).

What could be the easiest formula to do so, with matrices and/or quaternions?

2

There are 2 best solutions below

0
On

Here is a R function performing such a rotation:

# rotation around the plane (axis1,axis2)
rotation4Dplane <- function(axis1, axis2, theta, vector){
  # normalize the two axes
  c1 <- c(crossprod(axis1))
  c2 <- c(crossprod(axis2))
  axis1 <- axis1/sqrt(c1)
  axis2 <- axis2/sqrt(c2)
  #
  vx <- sum(vector*axis1)
  vy <- sum(vector*axis2)
  coef1 <- vx * cos(theta) - vy * sin(theta)
  coef2 <- vy * cos(theta) + vx * sin(theta)
  pvector <- vx*axis1 + vy*axis2 
  coef1*axis1 + coef2*axis2 + (vector-pvector)
}
# example: rotation of (1, 2, 3, 4) around the plane xy with angle pi/4
rotation4Dplane(c(1, 0, 0, 0), c(0, 1, 0, 0), pi/4, c(1, 2, 3, 4))

Maybe you don't know the R language but I think the syntax is intuitive enough. Tell me if you don't understand and I'll update this answer to translate in maths.

2
On

By "plane of rotation" it sounds like you want every point in that plane to remain fixed, as the axis of rotation remains fixed for a 3-d rotation. The complement would then be a plane being rotated by $\theta$

That means, after choosing a basis containing two basis vectors for the fixed plane, the transformation matrix would look like this:

$\begin{bmatrix}\cos(\theta)&\sin(\theta)&0&0 \\ -\sin(\theta)&\cos(\theta)&0&0 \\ 0&0& 1&0 \\ 0&0&0&1\end{bmatrix}$

where the upper left hand corner is doing a rotation on the plane complementary to the fixed plane by $\theta$.

So, given your starting coordinates and subspace, you could

  1. Change basis to an orthonormal basis with two vectors that are an orthonormal basis of the fixed subspace in the 3rd and 4th positions
  2. Apply the above rotation
  3. Unapply the change of basis.