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

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

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

v=S(n^,k)v
scale arbitrary axis

scale arbitrary axis

Separate v in 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]