# Matrix for 4D rotation around an arbitrary plane?

This topic is 3962 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm playing about with a program to draw a rotating Tesseract (it's a 4D Hypercube), and I'm wondering about some of the matrix maths that might be useful. I found (at the bottom of this page ) the matrices for rotating around the 6 planes you get in 4D. You'll recognise the first 3 of those matrices as the ones for rotating around the x, y and z axes in 3D (those axes are actually normals of planes), and the other 3 deal with rotations involving the w component. I got all this working rather nicely, but I'm wondering about rotations around arbitrary axes. You can do it in 3D, create a 3x3 rotation matrix from a normalised vector representing the axis, and an angle. I confess to being a bit mystified as to how those matrices work (in the past it has sufficed for me to treat rotation matrices as magic black boxes and not think about them too much). I'm wondering if and how you can create an arbitrary 4x4 rotation matrix, specified by a 4-dimensional axis (something with a w component as well as x,y and z ones), or perhaps rather 4 values representing an arbitrary plane. Thankfully my program doesn't do any translation, so I figure I can fit it all into a 4x4 matrix. Any help appreciated. Talking to me like I'm a slow-learning child when trying to explain stuff is encouraged, because although English is my first language and C++ my second, Maths comes in a really really distant third and I don't speak it nearly as fluently as the first two :)

##### Share on other sites
Unfortunately, this is a mathematical approach, but it does apply to any dimension space :)

Let exp(x) be the natural exponential function. Its power series is exp(x) = 1 + x/1! + x^2/2! + x^3/3! + ... + x^n/n! + ... . The power series converges for all real-valued x.

If S is a skew-symmetric matrix, then formally substitute S into the power series, replacing the first term 1 by I (the identity matrix) to obtain the matrix exp(S) = I + S/1! + S^2/2! + ... . This matrix is orthogonal and has determinant 1, so it represents a rotation. The power series is an infinite sum; the trick is to reduce this to a finite sum in order to obtain a computable rotation matrix.

For 2x2 matrices, S = {{0,a},{-a,0}}, which lists the matrix S by its rows. The number 'a' is any real number. Using terminology from linear algebra, the characteristic polynomial is 0 = det(S - t*I) = t^2 + a^2. If you formally substitute matrix S for scalar t in this polynomial, the equality still holds. In this example, it is the case that S^2 + a^2*I = 0. You can verify this by squaring S and seeing that it is -a^2*I. Using this to "bootstrap", you can compute S^3 = -a^2*S, S^4 = -a^2*S^2 = a^4*I, and so on. Substitute all these into the power series for exp(S). You have an infinite number of terms involving I and S. Partition these into exp(S) = (1 - a^2/2! + a^4/4! - ...)*I + (1 - a^2/3! + a^4/4! - ...)*S = cos(a)*I + (sin(a)/a)*S = {{cos(a),sin(a)},{-sin(a),cos(a)}}, which you will recognize as a 2x2 rotation matrix.

For 3x3 matrices, S = {{0,a,b},{-a,0,c},{-b,-c,0}}, where a, b, and c are any real numbers. The characteristic polynomial is 0 = -t^3 - (a^2+b^2+c^2)*t. Using the same procedure as in the last paragraph, you know that S^3 + (a^2+b^2+c^2)*S = 0. Define L^2 = (a^2+b^2+c^2). The power series for exp(S) can be factored into exp(S) = I + (sin(L)/L)*S + ((1-cos(L))/L^2)*S^2.

For 4x4 matrices, S = {{0,a,b,c},{-a,0,d,e},{-b,-d,0,f},{-c,-e,-f,0}}. The characteristic polynomial is 0 = t^4 + (a^2+b^2+c^2+d^2+e^2+f^2)*t^2 + (c*d-b*e+a*f)^2 = 0. This gives you the identity S^4 + k2*S^2 + k0*I = 0, where k2 = a^2+b^2+c^2+d^2+e^2+f^2 and k0 = (c*d-b*e+a*f)^2. You can use this to partition the power series: exp(S) = v0*I + v1*S + v2*S^2 + v3*S^3. As an exercise, I'll let you determine the coefficients v0 through v3 :)

Notice that at the web site you mention, the 6 rotation matrices are obtained by setting one of a, b, c, d, e, f to 1 and the others to zero. You can choose a random rotation by randomly selecting these 6 numbers.

##### Share on other sites
That was beautiful, Dave [smile].

##### Share on other sites
Quote:
 Original post by Dave EberlyYou can use this to partition the power series: exp(S) = v0*I + v1*S + v2*S^2 + v3*S^3. As an exercise, I'll let you determine the coefficients v0 through v3 :)

Determining these is not that simple. For entertainment, all the gory details are in Constructing Rotation Matrices Using Power Series. If you want to skip to the punch line, Section 4.3 lists the 6-parameter equation for 4D rotation matrices. This equation is the extension of Rodrigues' Formula for 3D rotation matrices.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632925
• Total Posts
3009235
• ### Who's Online (See full list)

There are no registered users currently online

×