Suppose one wants to confine the rotation of the hypercube to the third and
fourth dimensions, the most mysterious rotation of all. The rotation matrix
rot34
is applied. Its entries are O's, 1's and three other numbers
distributed according to the following pattern:
1 | 0 | 0 | 0 | ||
0 | 1 | 0 | 0 | ||
0 | 0 | a | b | ||
0 | 0 | -b | a |
The angle of the desired rotation in degrees is selected and stored in the
variable ang
, and the numbers a and b depend on
ang
: a is equal to cos(ang)
and b
is equal to sin(ang)
, where cos
and
sin
are the trigonometric functions sine and cosine.
The rule for generating the other five rotation matrixes is simple. The
a's appear on the main diagonal of each matrix in positions that
correspond to the dimensions affected by the rotation. The b's
appear at all the other intersections of rows and columns that correspond
to the rotating dimensions. All other entries on the main diagonal are 1's,
and the rest of the entries in the matrix are O's. For example,
rot13
is the following matrix:
a | 0 | b | 0 | ||
0 | 1 | 0 | 0 | ||
-b | 0 | a | 0 | ||
0 | 0 | 0 | 1 |