Z Rotation Cubing

  • The x, y, and z rotations will be the same rotations as used in FCN. My method is based off of two very easy algorithms. They're both four moves, and they are the same as the 'sledgehammer' (R' F R F') and the 'hedgeslammer' (F R' F' R) on a 3x3x3 cube.
  • I have some 3D points (in a cube shape shown as blue in the figure). I would like to rotate these points such that one face of the cube is normal to a line passing through the origin of the system (red dot in the figure) and the centre of the cube. I have tried a few things but it doesn't quite work and some edge cases throw the system way off.

You can plug in transform.rotation.eulerAngles.y to the second parameter of the above function, and it may work in some cases, but because the three Euler angles often all depend on each other in unpredictable ways, it's not a good idea.

Projecting 3D on 2D

A point in a three-dimensional coordinate system can be represented by a (3times 1) matrix. When modelling three dimensions on a two-dimensional computer screen, you must project each point to 2D. After the projection, each point is represented by a (2times 1) matrix.

Rotation

If we assume that the (z)-axes (or the third base vector) is pointing from the computer screen, then the screen is a projection on the (xy)-plane.

The projection matrix (mathbf{P}) must map the matrix (mathbf{v}=left( begin{array}{} abc end{array}right)) onto a matrix (mathbf{w}=left( begin{array}{} ab end{array}right)). This can be achieved by letting

[mathbf{P}=left( begin{array}{} 1 & 0 & 00 & 1 & 0 end{array}right)]

Z Rotation Cubing

Then let (mathbf{w}=mathbf{P}mathbf{v}).

Matrix as a visual point

In GeoGebra, matrices are represented by lists. A (2times 1) matrix is not shown in the drawing pad.

If you want to show a matrix (mathbf{matrix1}=binom{2}{1}) as a point, you must use the matrix elements as coordinates for a new point. You retrieve an element of a matrix by using the command Element[<matrix>, <row>, <column>].

To show a (2times 1)-matrix (mathbf{w}) as a point (A), you write:

Exercise 1

Z Rotation Cubing

  • Make three sliders to represent the matrix elements (v_x, v_y, v_z) of a matrix (mathbf{v}).

  • Create the matrix (mathbf{v}) by using the spreadsheet or by entering it as a list in the input bar: v={{v_x},{v_y},{v_z}}

  • Create the projection matrix (mathbf{P}).

  • Create the projected matrix (mathbf{w}=mathbf{P}mathbf{v}) in the input bar: w=P v

  • Create a point A, having the elements of (mathbf{w}) as coordinates.

  • Change the sliders. When changing the (v_z)-slider, nothing should happen with the point (A).

The rotations

If the z-axes points from the screen, and if you rotate the base vectors by an angle (alpha) around the z-axes, you get the rotated vectors as in the picture below.

The third base vector, that is parallel to the z-axes, does not change.

The rotation matrix (mathbf{T_z}) for rotation around the z-axes is:

Cubing

[mathbf{T_z}=left( begin{array}{ccc} cos alpha & -sin alpha & 0 sin alpha & cos alpha & 0 0 & 0 & 1 end{array} right) ]

In a similar way you can find the rotation matrices for rotation around the x- and the y-axes.

[mathbf{T_x}=left( begin{array}{ccc} 1 & 0 & 0 0 & cos alpha & -sin alpha 0 & sin alpha & cos alpha end{array} right) ]

[mathbf{T_y}=left( begin{array}{ccc} cos alpha & 0 & sin alpha 0 & 1 & 0 -sin alpha & 0 & cos alpha end{array} right) ]

Exercise 2

Z Rotation Cubing
  • Enter three sliders representing the three rotation angles, one angle per axes/base vector.

  • Enter three rotation matrices, one matrix for each angle.

  • Instead of just projecting the matrix (mathbf{v}) to 2D, it must now be rotated before the projection. Change the definition of the matrix (mathbf{w}) from (mathbf{w}=mathbf{Pv}) to (mathbf{w}=mathbf{PT_xT_yT_zv})

The Vertices of the Cube

The eight vertices of the cube must be transformed in the same way as the matrix v. The vertices must be rotated, projected, and represented by visual points. Since the same operations must be applied eight times, it is easiest to use the spreadsheet.

Let the cube have its vertices in at the coordinates (1,1,1), (1,-1,1), (-1,1,1), (-1,-1,1), (1,1,-1), (1,-1,-1), (-1,1,-1) and (-1,-1,-1).

One way to do the operations is to enter the coordinates in the spreadsheet and then:

  • Make a matrix of the coordinates of one point, then make relative copies of that matrix.

  • Perform the transformations on one matrix, then make relative copies of the result.

  • Make a point of one transformed matrix, then make relative copies of the point.

The operations are done in column A in the picture below. The relative copies are made by dragging to the right.

Rotate the points to fill in the sides of the cube by using the Polygon tool.

Z rotation cubing

It is of course possible to use other coordinates for the vertices of the cube.

Using the same spreadsheet, you can now rotate other 3D objects and project them on 2D.