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 an 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 operations can be represented as

scale arbitrary axis
Separate $\mathbf{v}$ in 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
References
- Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.