es

The Wolfram Mathematic notebook which contains the code that produces all the Mathematica output in this web page may be downloaded at this link. Caution: This notebook will evaluate, cell-by-cell, sequentially, from top to bottom. However, due to re-use of variable names in later evaluations, once subsequent code is evaluated prior code may not render properly. Returning to and re-evaluating the first Clear[ ] expression above the expression no longer working and evaluating from that point through to the expression solves this problem.

$Post := If[MatrixQ[#1], MatrixForm[#1], #1] & (* outputs matricies in MatrixForm*)
Remove[ "Global`*"] // Quiet (* remove all variables *)

In three-dimensional real space ℝ³, it is possible to implement the same strategy as in 2D and define primitive linear transformations of scaling, orthographic projection, reflection, rotation, and shearing. However, due to diversity of these basic transformations, it is difficult to classify and illustrate all possible cases within every basic transformation. It turns out that we can successfully visualize only two kinds of primitive transformations---projections (this topic will be discussed later in detail) and rotations---when objects are transformed as whole while the coordinate space remains stationary.

3D Transformations

Once matrices corresponding to primitive linear transformations are identified, we can multiply these matrices to obtain corresponding compositions of transformations. This is the main reason why we are working with matrices as linear operators.

 

Scaling in 3D space


We start with scaling along the cardinal axes. For example, scaling along the cardinal axes can be determined by the matrix that is a product of simple scaling matrices:
\[ {\bf S}\left( k_1 , k_2 , k_3 \right) = \begin{bmatrix} k_1 & 0 & 0 \\ 0 & k_2 & 0 \\ 0&0&k_3 \end{bmatrix} = \begin{bmatrix} k_1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \cdot \begin{bmatrix} 1 & 0 & 0 \\ 0 & k_2 & 0 \\ 0&0&1 \end{bmatrix} \cdot \begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0& k_3 \end{bmatrix} , \]
where the order of multiplications at the right-hand side does not matter. As you see from the formula above, a general nonuniform scaling along the cardinal axes can be reduces to composition of simple scaling transformations with respect to a single axis.    
code: make an example
   ■
End of Example 1

We can construct a general scale matrix along a particular vector, which direction is identified by a unit vector \( \displaystyle \hat{\bf n} = \left( n_x , n_y , n_z \right) . \) To achieve this, we go ahead following the procedure described in the previous section.

Suppose we want to scale by factor k in the directions identified by vector n. This operation we accomplish by matrix multiplication

\[ \mathbf{v} = \mathbf{S} \left( \hat{\bf n}, k \right) \mathbf{x}, \qquad \mathbf{v}, \mathbf{x} \in \mathbb{R}^{3\times 1} . \]
Separate x in two vectors, a vector parallel to n called x and a vector perpendicular to n called x such that
\[ \mathbf{x} = \mathbf{x}_{\perp} + \mathbf{x}_{\|} . \]
These vectors are expressed through the original vector x as
\begin{align*} \mathbf{x}_{\|} &= \left( \mathbf{x} \bullet \hat{\bf n} \right) \hat{\bf n} , \\ \mathbf{x}_{\perp} &= \mathbf{x} - \mathbf{x}_{\|} \end{align*}
We can also represent v as a sum of two vectors parallel and perpendicular to n:
\[ \mathbf{v} = \mathbf{v}_{\perp} + \mathbf{v}_{\|} . \]
Any vector perpendicular to n is not affected by scale operation, therefore, v = x + v. Since x is parallel to the direction of scale then v = kx

Reconstructing the solution from the observations above

\begin{align*} \mathbf{v}_{\perp} &= \mathbf{x}_{\perp} = \mathbf{x} - \left( \mathbf{x} \bullet \hat{\bf n} \right) \hat{\bf n} , \\ \mathbf{v}_{\|} &= k\,\mathbf{x}_{\|} = k \left( \mathbf{x} \bullet \hat{\bf n} \right) \hat{\bf n} , \\ \mathbf{v} &= \mathbf{v}_{\|} + \mathbf{v}_{\perp} \\ &= \mathbf{x} + \left( k-1 \right) \left( \mathbf{x} \bullet \hat{\bf n} \right) \hat{\bf n} . \end{align*}
Then the corresponding scaling matrix becomes
\[ {\bf S} \left( \hat{\bf n}, k \right) = \begin{bmatrix} 1 + \left( k-1 \right) n_x^2 & \left( k-1 \right) n_x n_y & \left( k-1 \right) n_x n_z \\ \left( k-1 \right) n_x n_y & 1 + \left( k-1 \right) n_y^2 & \left( k-1 \right) n_y n_z \\ \left( k-1 \right) n_x n_z & \left( k-1 \right) n_y n_z & 1 + \left( k-1 \right) n_z^2 \end{bmatrix} . \]
Based on numerical value of parameter k ∈ ℝ to be either greater than 1 of less than 1, this scaling transformation defines an amount to be enlarged or shrinked.
   ■
End of Example 2

 

Rotations

 

Shearing in 3D space


Shearing is a transformation that skews the coordinate space. We abbreviate shear matrices with Cyrillic letter "Ш," which is pronounced as "sha" in English or "ch" in French. Shear 2-by-2 matrices can operate either on column vectors from left or on row vectors from right. We distinguish these operators by writing them in either brackets of in parentheses;
\begin{equation} \label{EqShear.1} {\bf Ш}_{xy} = \begin{bmatrix} 1 & 0&\alpha \\ 0 & 1 &\beta \\ 0&0&1 \end{bmatrix} \quad \Longrightarrow \quad {\bf Ш}_{xy} (\alpha , \beta ) \begin{pmatrix} x \\ y \\ z \end{pmatrix} = \begin{bmatrix} x + \alpha \,z \\ y + \beta\, z \\ z \end{bmatrix} . \end{equation}
< Similarly, a shear matrix acting on row vectors from right is
\begin{equation} \label{EqShear.2} {\bf Ш}_{xy} (\alpha , \beta ) = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ \alpha & \beta & 1 \end{pmatrix} \end{equation}
and so
\[ \left[ x, \ y , \ z \right] {\bf Ш}_{xy} (\alpha , \beta ) = \begin{bmatrix} x + \alpha\,z , \ y+ \beta\, z , \ z \end{bmatrix} . \]
Other shearing matrices in the x, z and y, z coordinates are
\begin{equation} \label{EqShear.3} {\bf Ш}_{xz} = \begin{bmatrix} 1 &\alpha &0 \\ 0 & 1 &0 \\ 0&\beta &1 \end{bmatrix} \quad \Longrightarrow \quad {\bf Ш}_{xz} (\alpha , \beta ) \begin{pmatrix} x \\ y \\ z \end{pmatrix} = \begin{bmatrix} x + \alpha \,y \\ y \\ z + \beta\,y \end{bmatrix} , \end{equation}
and
\begin{equation} \label{EqShear.4} {\bf Ш}_{yz} = \begin{bmatrix} 1 & 0&0 \\ \alpha & 1 &0 \\ \beta&0&1 \end{bmatrix} \quad \Longrightarrow \quad {\bf Ш}_{yz} (\alpha , \beta ) \begin{pmatrix} x \\ y \\ z \end{pmatrix} = \begin{bmatrix} x \\ y + \alpha\, x \\ z + \beta\,x \end{bmatrix} . \end{equation}
When shear matrices are acing on row vectors, these matrices are written as
\[ {\bf Ш}_{xz} = \begin{pmatrix} 1&0&0 \\ \alpha & 1 & \beta \\ 0&0&1\end{pmatrix} \quad \mbox{and} \quad {\bf Ш}_{yz} = \begin{pmatrix} 1& \alpha & \beta \\ 0&1&0 \\ 0&0&1 \end{pmatrix} . \]
Example 2:    ■
End of Example 2


  1. Anton, Howard (2005), Elementary Linear Algebra (Applications Version) (9th ed.), Wiley International
  2. Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.
  3. Foley, James D.; van Dam, Andries; Feiner, Steven K.; Hughes, John F. (1991), Computer Graphics: Principles and Practice (2nd ed.), Reading: Addison-Wesley, ISBN 0-201-12110-7
  4. Matrices and Linear Transformations