3D Transformations
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.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. 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
We can construct a general scale matrix along a particular vector u by computing the resulting matrix as follows. Let \( \displaystyle \hat{\bf n} = \left( n_x , n_y , n_z \right) \) be a unit vector along the given vector u ∈ ℝ³, and k ∈ ℝ be a parameter that defines an amount to be enlarged or shrinked. 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} .
\]
Rotation in 3D space
- Anton, Howard (2005), Elementary Linear Algebra (Applications Version) (9th ed.), Wiley International
- Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.
- 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
- Matrices and Linear Transformations