Transformations in space

Ivan Cnop
Vrije universiteit Brussel
icnop@vub.ac.be

Vectors and polygons

Tripods in space

Programming this structure may remain hidden from the user

To hide this programming in Mathematica, write the following cells in white text. 
Make shure we are in three dimensions:

vector3[u_List] := (Length[u] == 3)

vector3[{x, y}]

vector3[{x, y, z}]

basis3 = NestList[RotateRight, {1, 0, 0}, 2]

Clear[tripod]

tripod[{u_, v_, w_}] := NestList[RotateLeft, {u, v, w}, 2]

tripod[{u, v, w}]

tripod2[{u_, v_, w_}] := 
      Table[Take[tripod[{u, v, w}][[j]], 2], {j, 
          Length[{u, v, w}]}]

tripod2[{u, v, w}]

tripod2[basis3]

% // ColumnForm

Clear[quadrangle]

quadrangle[{u_, v_}] := 
      Polygon[{0 u, u, u + v, v}] /; Length[u] == Length[v]

\(quadrangle[{u_, v_, w_}] := 
	{Polygon[{0\ u, u, u + v, v}], 
        Polygon[{w, u + w, u + v + w, v + w}]}\)

Quadrangles spanned by  two vectors

Example

<< Default3D`

Show[Graphics3D[quadrangle[{{1, 0, 1}, {2, 1, 0}}]]]

Translate

Show[
      Graphics3D[quadrangle[{{1, 0, 1}, {2, 1, 0}, {0, 0, 1}}]]]

Show[%, ViewPoint -> 5 ({1, 0, 1} + {2, 1, 0})]

Show[Graphics3D[quadrangle[basis3]]]

Show[%, %%]

If the third vector is a combination of the other two, the figure collapses:

Show[
      Graphics3D[
        quadrangle[{{1, 0, 1}, {2, 1, 
              0},  .5 {1, 0, 1} -  .8 {2, 1, 0}}]]]

Best seen from the side:

Show[%, ViewPoint -> 5 ({1, 0, 1} + {2, 1, 0})]

Spanning the unit cube

basisPolygon = Map[quadrangle, tripod2[basis3]]

Show[Graphics3D[%]]

Action of matrices on the unit cube

Any matrix

Write your own

A=(({{1 , .5, 1}, {0, 2, 0}, {1, 0, .5}}))

A // MatrixForm

IMPORTANT:  It is wrong to  apply    A Dot    to the   "list"  of basis vectors ! 
Doing this  we get  lines of the matrix, not its columns !!!!

A . basis3

Here is the right image

Map[A . # &, basis3] // ColumnForm

Transpose[Map[A . # &, basis3]] // MatrixForm

% == A

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

The result is a deformation of the three squares into three parallellograms. 
The unit cube is transformed into a skewed volume obtained by closing of these three paralellograms by adding three more parallel ones.

Multiple in one direction

A=(({{1 , 0, 0}, {0, 2.5, 0}, {0, 0, 1}}))

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

Shear transform

In one direction

A=(({{1 , 0, 0}, {0, 1, 0.5}, {0, 0, 1}}))

Det[A]

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

In two directions

A=(({{1 , 0, 0.7}, {0, 1, 0.5}, {0, 0, 1}}))

Det[A]

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

Another example:

A=(({{1 , 0, 0}, {.7, 1, 0}, {1, 0, 1}}))

Det[A]

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

Reflection with respect to a plane

A=(({{1 , 0, 0}, {0, -1, 0}, {0, 0, 1}}))

Det[A]

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

Remark:

The images will not always sit in the same octant as the unit cube.
Her is a more striking example

A=(({{1 , -.5, 0}, {0, 1, -.5}, {-.5, 0, 1}}))

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

Rotation in the x-y plane

alfa = π/3

A=(({{Cos[alfa] , -Sin[alfa], 0}, {Sin[alfa], Cos[alfa], 0}, {0, 0, 1}}));

A // MatrixForm

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Show[Graphics3D[{basisPolygon, %}]]

Exercise:

Write out rotations around the x-axis and around the y-axis.

An animation

alfa =.

A=(({{Cos[alfa] , -Sin[alfa], 0}, {Sin[alfa], Cos[alfa], 0}, {0, 0, 1}}));

A // MatrixForm

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Do[Show[{Graphics3D[{Point[{2, 2, 2}], 
              Point[{-2, -2, -2}]}], 
          Graphics3D[{basisPolygon, %}]}, 
        BoxRatios -> {1, 1, 1}, ], {alfa, 0, 
        2  π, π/8}]

In this animation the extra points fix the size of the graphic.

Another animation combining rotations around two axes

Let  us make a full turn around the vertical axis and a half turn around another axis (which one?)

alfa =.

A=(({{Cos[alfa] , -Sin[alfa], 0}, {Sin[alfa], Cos[alfa], 0}, {0, 0, 1}})).(({{Cos[alfa/2] , 0, -Sin[alfa/2]}, {0, 1, 0}, {Sin[alfa/2], 0, Cos[alfa/2]}}));

A // MatrixForm

Map[quadrangle, tripod2[Map[A . # &, basis3]]];

Do[Show[{Graphics3D[{Point[{1.5, 1.5, 1.5}], 
              Point[{-1.5, -1.5, -1.5}]}], 
          Graphics3D[{basisPolygon, %}]}, 
        BoxRatios -> {1, 1, 1}], {alfa, 0, 
        2  π, π/12}]

Remark:

Additional commands concerning matrix manipulation i Mathematica are in

<< LinearAlgebra`MatrixManipulation`;