This article is part 2 in the series about transformation matrices:

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:

p=kxp=kx[10]=[kx0]q=kyq=ky[01]=[0ky]

Constructing the 2D scale matrix S(kx,ky) from these basis vectors:

S(kx,ky)=[kx00ky]

Similarly, the 3D scale matrix is given by:

S(kx,ky,kz)=[kx000ky000kz]

Scaling Along an Arbitrary Axis

Let 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:

v=S(n^,k)v
Scale Arbitrary Axis

Scale Arbitrary Axis

Separate v into two vectors: a vector parallel to v^ called v and a vector perpendicular to v^ called v such that:

v=v+v

Where:

v=(vn^)n^v=vv

We can also represent v as a sum of two vectors parallel and perpendicular to n^:

v=v+v

Note that any vector that lies in the 2D line or 3D plane perpendicular to n^ will not be affected by the scale operation, so v=v+v.

Since v is parallel to the direction of scale, then v=kv.

Reconstructing the solution from the observations above:

v=(vn^)n^v=v=vv=v(vn^)n^v=kv=k(vn^)n^v=v+v=v(vn^)n^+k(vn^)n^=v+(k1)(vn^)n^

We can construct a general scale matrix by computing the vectors resulting after transforming the basis vectors p, q, and r. For example, let’s transform p=[100]T:

p=p+(k1)(pn^)n^=[100]+(k1)([100][nxnynz]T)[nxnynz]=[100]+(k1)nx[nxnynz]=[1+(k1)nx2(k1)nxny(k1)nxnz]

Similarly, the values of q and r can be found, which make the general rotation matrix equal to:

S(n^,k)=[pqr]=[1+(k1)nx2(k1)nynx(k1)nznx(k1)nxny1+(k1)ny2(k1)nzny(k1)nxnz(k1)nynz1+(k1)nz2]