This article is part 2 in the series about transformation matrices:
- Part 1: Coordinate systems and transformations between them
- Part 2: Scaling objects with a transformation matrix (this article)
- Part 3: Shearing objects with a transformation matrix
- Part 4: Translating objects with a transformation matrix
- Part 5: Combining Matrix Transformations
Scaling Along the Cardinal Axes
Intuitively, the basis vectors should be multiplied by a scalar. Also, they are independently affected by the scale factors.
In 2D, the basis vectors become:
Constructing the 2D scale matrix $\mathbf{S}(k_x, k_y)$ from these basis vectors:
Similarly, the 3D scale matrix is given by:
Scaling Along an Arbitrary Axis
Let $\unit{n}$ be the unit vector parallel to the direction of scale and $k$ to be the scale factor. A vector transformed by this scale operation can be represented as:
Scale Arbitrary Axis
Separate $\mathbf{v}$ into two vectors: a vector parallel to $\unit{v}$ called $\mathbf{v_{\parallel}}$ and a vector perpendicular to $\unit{v}$ called $\mathbf{v_{\perp}}$ such that:
Where:
We can also represent $\mathbf{v’}$ as a sum of two vectors parallel and perpendicular to $\unit{n}$:
Note that any vector that lies in the 2D line or 3D plane perpendicular to $\unit{n}$ will not be affected by the scale operation, so $\mathbf{v’} = \mathbf{v_{\parallel}’} + \mathbf{v_{\perp}}$.
Since $\mathbf{v_{\parallel}}$ is parallel to the direction of scale, then $\mathbf{v_{\parallel}’} = k\mathbf{v_{\parallel}}$.
Reconstructing the solution from the observations above:
We can construct a general scale matrix by computing the vectors resulting after transforming the basis vectors $\mathbf{p}$, $\mathbf{q}$, and $\mathbf{r}$. For example, let’s transform $\mathbf{p} = \begin{bmatrix} 1 & 0 & 0 \end{bmatrix}^T$:
Similarly, the values of $\mathbf{q’}$ and $\mathbf{r’}$ can be found, which make the general rotation matrix equal to: