[comp.graphics] 4-Space Basis Rotation Matrices

hollasch@enuxha.eas.asu.edu (Steve Hollasch) (08/10/90)

    I'm writing a 4D wireframe-viewer and have run into the problem of
generating rotation matrices for the 4D viewpoint.  What are the basis
rotation matrices in 4D?  The 4-space viewpoint will be on the surface
of a hypersphere, and I want a set of basis rotations that can rotate
the point to any other point on the surface of that hypersphere.  In
addition, the rotation needs to be parametric, since I'll be tying the
rotation angle to the cursor for a smooth rotation.  Hence, I don't
want reflections or other improper rotations.

    I think that two rotation matrices are sufficient in 3-space;
consider spherical coordinates with a fixed radial length.  If this is
true, I'd also like to know what the analogous 4-space rotation
matrices would be.

    So how do you find the set of 4-space rotation matrices?  I can't
think of a way to rotate about the basis vectors in 4-space, since
traditional rotation matrices deal with rotations in a plane.  One
suggested approach is to include each 3-space rotation matrix in a 4x4
matric for each row/column pair replaced with the identity row/column,
e.g.  ( S = sin(theta), C = cos(theta) ):

    +-          -+   +-          -+   +-          -+   +-          -+
    | 1  0  0  0 |   | 1  0  0  0 |   | 1  0  0  0 |   | C  0 -S  0 |
    | 0  C  S  0 |   | 0  C  0 -S |   | 0  1  0  0 |   | 0  1  0  0 |
    | 0 -S  C  0 |   | 0  0  1  0 |   | 0  0  C  S |   | S  0  C  0 |
    | 0  0  0  1 |   | 0  S  0  C |   | 0  0 -S  C |   | 0  0  0  1 |
    +-          -+,  +-          -+,  +-          -+,  +-          -+, 

    and so on, for a total of twelve matrices.

    Are these twelve matrices sufficient to parametrically rotate a 4D
viewpoint on the 4-sphere to any other viewpoint on the 4-sphere?  Are
they all _necessary_ (like only needing two rotations in 3-space)?

    Any comments or literature references?
-- 
______________________________________________________________________________
Steve Hollasch                       Arizona State University / Tempe, Arizona
hollasch@enuxha.eas.asu.edu  /  uunet!mimsy!oddjob!noao!asuvax!enuxha!hollasch
                          Is this my opinion yet?

jroth@allvax.dec.com (Jim Roth) (08/11/90)

In article <1279@enuxha.eas.asu.edu>, hollasch@enuxha.eas.asu.edu (Steve Hollasch) writes...
> 
>    I'm writing a 4D wireframe-viewer and have run into the problem of
>generating rotation matrices for the 4D viewpoint.  What are the basis
>rotation matrices in 4D?  The 4-space viewpoint will be on the surface
>of a hypersphere, and I want a set of basis rotations that can rotate
>the point to any other point on the surface of that hypersphere.  In
>addition, the rotation needs to be parametric, since I'll be tying the
>rotation angle to the cursor for a smooth rotation.  Hence, I don't
>want reflections or other improper rotations.
> 
>    I think that two rotation matrices are sufficient in 3-space;
		  ^^^
Actually, 3 are necessary (think of Euler angles.)

>consider spherical coordinates with a fixed radial length.  If this is
>true, I'd also like to know what the analogous 4-space rotation
>matrices would be.
> 
>    So how do you find the set of 4-space rotation matrices?  I can't
>think of a way to rotate about the basis vectors in 4-space, since
>traditional rotation matrices deal with rotations in a plane.  One
>suggested approach is to include each 3-space rotation matrix in a 4x4
>matric for each row/column pair replaced with the identity row/column,
>e.g.  ( S = sin(theta), C = cos(theta) ):
> 
>    +-          -+   +-          -+   +-          -+   +-          -+
>    | 1  0  0  0 |   | 1  0  0  0 |   | 1  0  0  0 |   | C  0 -S  0 |
>    | 0  C  S  0 |   | 0  C  0 -S |   | 0  1  0  0 |   | 0  1  0  0 |
>    | 0 -S  C  0 |   | 0  0  1  0 |   | 0  0  C  S |   | S  0  C  0 |
>    | 0  0  0  1 |   | 0  S  0  C |   | 0  0 -S  C |   | 0  0  0  1 |
>    +-          -+,  +-          -+,  +-          -+,  +-          -+, 
> 
>    and so on, for a total of twelve matrices.
			       ^^^^^^
Only 6 are necessary.

> 
>    Are these twelve matrices sufficient to parametrically rotate a 4D
>viewpoint on the 4-sphere to any other viewpoint on the 4-sphere?  Are
>they all _necessary_ (like only needing two rotations in 3-space)?
> 

The conceptual problem is that one cannot rotate "about" an axis; rather
one can rotate "in a plane" or 2 dimensional subspace in n dimensions.
More generally, an n dimensional orthogonal rotation can be expressed in terms
of (n choose 2) parameters.  In 3 space this happens to be 3 - a remarkable
coincidence which allows us to think of axes of rotation and so on.

One way to see this is that an n by n matrix has n^2 components; but
we also require that the rows and colums be orthonormal, which cuts the
degrees of freedom down to (n choose 2).  The manifold of possible
rotations can be thought of as an algebraic variety (hypersurface)
in n^2 space.  It is a Riemannian manifold, meaning roughly that one
has the notion of distance, geodesics, and so forth.

One way of decomposing your rotations is to have a set of (4 choose 2) or
6 plane rotation matrices, one for each possible pair of coordinate
axes.  (You do not need 12 matrices.)  This is analogous to Euler angles
in 3 space.

Another is to "exponentiate" a general skew symmetric matrix.  Choose
a skew matrix with 6 free parameters and calculate the matrix series

	EXP(S) = I + S + S^2/2! + S^3/3! + ...

where S is of the form

	|  0    p1  p2  p3 |
	| -p1   0   p4  p5 |
	| -p2  -p4  0   p6 |
	| -p3  -p5 -p6  0  |

In 3 dimensions, such skew matrix has the 3 parameters representing a
vector whose length is the angle of rotation in radians and whose direction
is the axis of rotation.

Try it, and you'll find that the resulting matrix is indeed a proper
orthogonal rotation.

In fact, you can go the other way and take the log of an orthogonal matrix
and you'll wind up with a skew matrix giving the parameters for the
rotation it represents.  You can use the series

	O = I+X		an orthogonal matrix as a sum of X and the identity

	S = LOG(I+X) = X - X^2/2 + X^3/3 - X^4/4 + ...

An advantage of the exponential form is that you can parameterize it via

	O(t) = EXP(t*S)	where S = a skew matrix and t is a parameter

This lets you follow a geodesic arc on the group manifold.  Note that S
represents the tangent space to the manifold.

If you wish to rotate by an angle in an arbitrary plane spanned by a pair of
unit orthogonal vectors, say T and N, the matrix can be written

	        t      t		   t      t
	I + (N N  + T T ) (1-cos(t)) + (N T  - T N ) sin(t)

where you take the outer products of the unit vectors to make the matrices;
the little "t" means transpose.

It's worth remarking that there is a rational parameterization of rotations
called the Cayley parameterization.  One calculates

	S = (I-O)/(I+O)		S = skew matrix, O = orthogonal matrix
				1/(I+O) = matrix inverse

The inverse is the same

	O = (I-S)/(I+S)

In 3 space this can be used to parameterize rotations in terms of quaternions.
Since the expression for O is homogenous, rewrite it as

	O = (q0*I - S)/(q0*I + S)

	    | 0    q1  q2 |
	S = | -q1  0   q3 |
	    | -q2 -q3  0  |

Then the unit quaternion will be

	q0	   = cos(theta/2),
	(q1,q2,q3) = sin(theta/2) * (unit vector along axis of rotation)

There is a similar experssion in n-space, but without the nice geometric
interpretation of axis of rotation that we have in 3-space.

This is analogous to a conformal transformation in complex variables which
maps the unit disc to the half plane; in n-space it involves stereographic
projection of an n+1 sphere instead of the 2-sphere (Riemann sphere) of
ordinary complex variables.

Here's a little book that you may find interesting:

	"Matrix Groups" by M. Curtis,
	Springer Verlag Universitext 1984

Some of this subject matter is standard linear algebra.  Strang's book is
one of the best introductions for this.

- Jim

jroth@allvax.dec.com (Jim Roth) (08/13/90)

In article <2494@ryn.esg.dec.com>, jroth@allvax.dec.com (Jim Roth) writes...
> 
>In article <1279@enuxha.eas.asu.edu>, hollasch@enuxha.eas.asu.edu (Steve Hollasch) writes...
>> 
>>    I'm writing a 4D wireframe-viewer and have run into the problem of
>>generating rotation matrices for the 4D viewpoint.  What are the basis
>>rotation matrices in 4D?

[ stuff deleted ... ]

I just wanted to make a correction in my reply about Euler angles.  Though it is
true that there are 6 pairs of coordinate axes in 4 space, the correct
composition of generalized Euler angle matrices does not involve matrices
actually containing rotations in all these planes.

Consider an n-1 dimensional rotation which fixes the n'th coordinate axis.
This is a general rotation in n-1 space.  If this is followed with a
rotation which takes the n'th coordinate axis to an arbitrary point on the
n-sphere you can inductively generate arbitrary Euler angle rotations.

A systematic way to do this is to apply successive plane rotations in
the (k,k-1) plane, then the (k-1,k-2) plane, ... then the (1,2) plane
for k = 2 to n.  Of course, this adds up to n(n-1)/2 matrices total.

Thus in 4-D the series would be (assuming you multiply with column vectors
on the right):

    | C -S  0  0 | | 1  0  0  0 | | 1  0  0  0 |
    | S  C  0  0 | | 0  C -S  0 | | 0  1  0  0 |
    | 0  0  1  0 | | 0  S  C  0 | | 0  0  C -S |
    | 0  0  0  1 | | 0  0  0  1 | | 0  0  S  C |

      (1,2) plane    (2,3) plane    (3,4) plane

    | C -S  0  0 | | 1  0  0  0 |
    | S  C  0  0 | | 0  C -S  0 |
    | 0  0  1  0 | | 0  S  C  0 |
    | 0  0  0  1 | | 0  0  0  1 |

      (1,2) plane    (2,3) plane

    | C -S  0  0 |
    | S  C  0  0 |
    | 0  0  1  0 |
    | 0  0  0  1 |

      (1,2) plane

   That is, your rotation matrix would be

	(1,2) * (2,3) * (3,4) * (1,2) * (2,3) * (1,2)

    - Jim

hussein@bora.inria.fr (Hussein Yahia) (08/13/90)

<1279@enuxha.eas.asu.edu>, hollasch@enuxha.eas.asu.edu (Steve Hollasch)
writes...

>>    I'm writing a 4D wireframe-viewer and have run into the problem of
>>generating rotation matrices for the 4D viewpoint.  What are the basis
>>rotation matrices in 4D?


  Let f be an isometry of the n dimensional space. Then, according to a 
theorem of algebra, there exists subspaces E1, E2, ..., Eq, F1, ..., Fr
orthogonal each others, such that the sum

       E1 + E2 + ... + F1 + ... + Fr is direct and such that:


    - dimension of Ei = 2, dimension of Fj = 1,
    - the restriction of f to Ei is a 2 - dimensional rotation,
    - the restriction of f to Fj is either Identity or a central symmetry.



  So, if n = 3 we get the standard basis for a 3 - dimensionnal rotation:

                 cos(a)      -sin(a)        0
                 sin(a)       cos(a)        0
                   0            0           1


  If n = 4, the theorem implies that EVERY rotation matrix in 4-space can
be put in the following form:


                 cos(a)       -sin(a)       0         0
                 sin(a)        cos(a)       0         0
                   0             0         cos(b)    -sin(b)
                   0             0         sin(b)     cos(b)

in a suitable basis.

Hence a 4-rotational matrix does not have an axis, and it has 2 angles, and
we see from the preceding form that is is merely the commutative product of 
two 2-dimensionnal rotations acting on two orthogonal planes in 4 dimensional
space.



  Hussein Yahia
  INRIA
  Syntim Project
  BP 105 78153 le Chesnay Cedex
  France.

  E-mail: hussein@bora.inria.fr

falk@peregrine.Sun.COM (Ed Falk) (08/14/90)

In article <1538@seti.inria.fr> hussein@bora.inria.fr (Hussein Yahia) writes:
>
>
><1279@enuxha.eas.asu.edu>, hollasch@enuxha.eas.asu.edu (Steve Hollasch)
>writes...
>
>>>    I'm writing a 4D wireframe-viewer and have run into the problem of
>>>generating rotation matrices for the 4D viewpoint.  What are the basis
>>>rotation matrices in 4D?
>
>  If n = 4, the theorem implies that EVERY rotation matrix in 4-space can
>be put in the following form:
>
>
>                 cos(a)       -sin(a)       0         0
>                 sin(a)        cos(a)       0         0
>                   0             0         cos(b)    -sin(b)
>                   0             0         sin(b)     cos(b)
>

I think a simpler way to think of it is this:  the idea that rotations
are around an *axis* is incorrect.  It just happens to work in
three dimensions.  In fact, rotations occur within a *plane*.  In
4D, there are six planes (XY, XZ, XW, YZ, YW, ZW) and the rotations
through those various planes are

     cos(a)  -sin(a)	0	0
     sin(a)   cos(a)	0	0
	0	0	1	0	XY plane
	0	0	0	1

     cos(a)	0   -sin(a)	0
	0	1	0	0	XZ plane
     sin(a)	0    cos(a)	0
	0	0	0	1

     cos(a)	0	0    -sin(a)
	0	1	0	0	XW plane
	0	0	1	0
     sin(a)	0	0     cos(a)

and so on.

	-ed falk, sun microsystems -- sun!falk, falk@sun.com
	"What are politicians going to tell people when the
	Constitution is gone and we still have a drug problem?"
			-- William Simpson, A.C.L.U.

fenn@wpi.wpi.edu (Brian Fennell) (08/14/90)

In article <140587@sun.Eng.Sun.COM> falk@peregrine.Sun.COM (Ed Falk) writes:
...
>I think a simpler way to think of it is this:  the idea that rotations
>are around an *axis* is incorrect.  It just happens to work in
>three dimensions.  In fact, rotations occur within a *plane*.  In
>4D, there are six planes (XY, XZ, XW, YZ, YW, ZW) and the rotations
>through those various planes are
...
>	-ed falk, sun microsystems -- sun!falk, falk@sun.com
....

Granted that the idea of rotation in 4D seems to best apply to manipulating
points in (or around) a plane, but that brings up the question: are
there any 4D manipulations that are not the aforementioned
rotation, and still maintain the integrity of the object?  By
maintaining integrity" I mean that any given point A maintains its
distance from any other 5 non-co-spatial (not in the same 3-space) points 
B, C, D, E, and F.  

Hmmm, this seems to be getting out of the "graphics" arena.  What other
news groups would tailored to this discussion?

Brian Fennell == fenn@wpi.wpi.edu

jroth@allvax.dec.com (Jim Roth) (08/15/90)

In article <14503@wpi.wpi.edu>, fenn@wpi.wpi.edu (Brian Fennell) writes...
>In article <140587@sun.Eng.Sun.COM> falk@peregrine.Sun.COM (Ed Falk) writes:
>....
>>I think a simpler way to think of it is this:  the idea that rotations
>>are around an *axis* is incorrect.  It just happens to work in
>>three dimensions.  In fact, rotations occur within a *plane*.  In
>>4D, there are six planes (XY, XZ, XW, YZ, YW, ZW) and the rotations
>>through those various planes are
>....
>>	-ed falk, sun microsystems -- sun!falk, falk@sun.com

   If you want interactive view manipulation, I recommend providing a
   set of 6 valuators (for the 6 possible "planes") and a toggle button
   for pre or post concatenation (which corresponds to view or object
   centered rotatins.)

   Then use your valuators to generate incremental plane rotations which
   are composed into your "running" rotation matrix.

   I did this in a 4D wireframe viewer a long time ago, and it worked
   very well.  Looked real neat to see rotations involving the 4-th
   dimension - things would turn inside out!

   As an alternative to valuators (which should be free turning thumbwheels
   rather than slidepots) you can provide a set of radio buttons and measure
   mouse motion (horizontal, say) in the graphics area for your valuation.
   I like this approach since it takes less screen real estate and moving
   the mouse near the graphics gives a direct manipulation feel.

>Granted that the idea of rotation in 4D seems to best apply to manipulating
>points in (or around) a plane, but that brings up the question: are
>there any 4D manipulations that are not the aforementioned
>rotation, and still maintain the integrity of the object?  By
>maintaining integrity" I mean that any given point A maintains its
>distance from any other 5 non-co-spatial (not in the same 3-space) points 
>B, C, D, E, and F.  

    Any matrix whose rows (or columns) are orthonormal (mutually
    orthogonal vectors) will preserve distances.  Some of the responses
    show how such a matrix can be built up in a general way.

- Jim

mitchell@cbmvax.commodore.com (Fred Mitchell - Product Assurance) (08/17/90)

In article <2494@ryn.esg.dec.com> jroth@allvax.dec.com (Jim Roth) writes:
>
>The conceptual problem is that one cannot rotate "about" an axis; rather
>one can rotate "in a plane" or 2 dimensional subspace in n dimensions.

Or more to the point, one rotates ABOUT a plane in 4-space, as one
rotates ABOUT a line in 3-space. One would also rotate about a 3-space
in 5-space, etc. The dimension of your 'axis' of rotation in n-space
is always n-2.

In the 4-space example, rotating about a plane is fun to try to 
conceptualize. You dont pass thru the plane-axis of rotation, as
one might at first think; rather you go around it. It only appears
that you pass through it when looking at it from a 3-space (shadow)
perspective. You need a 4th-dimensional eye to truly visualize
this nightmare! :-)

-Mitchell

We are trapped in our lonely 3-D world. We miss out on so much.