1,0,0; Rotate Z → 45; Rotate axis → 90,1,0,0; Scale → 2,2,2
Interactive tool to build a single 4×4 transform matrix from translation rotation and scale then apply it to 3D points for conversion between local and global coordinates.
This online utility composes a sequence of elementary operations into one 4×4 homogeneous matrix and applies it to a list of 3D points. Use it to assemble transforms, convert coordinates between local and global systems, test transform order and validate CAD or animation pipelines. The phrase coordinate transform appears here once to match indexing.
How it works
Points are represented in homogeneous form as column vectors p = [x y z 1]ᵀ and transformed by a single matrix M_total so that p′ = M_total p. Building one matrix is faster and avoids repeated per-point math when many points share the same transform.
$$
p’ = M_{\mathrm{total}}\,p,\qquad
p=\begin{pmatrix}x\\[4pt]y\\[4pt]z\\[4pt]1\end{pmatrix}
$$
- \(p\) — input point in homogeneous coordinates;
- \(p’\) — transformed (global) point;
- \(M_{\mathrm{total}}\) — the final \(4\times4\) matrix of the composed transforms.
Basic transform matrices
Translation:
$$
T(t_x,t_y,t_z)=
\begin{pmatrix}
1 & 0 & 0 & t_x\\[4pt]
0 & 1 & 0 & t_y\\[4pt]
0 & 0 & 1 & t_z\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Scale:
$$
S(s_x,s_y,s_z)=
\begin{pmatrix}
s_x & 0 & 0 & 0\\[4pt]
0 & s_y & 0 & 0\\[4pt]
0 & 0 & s_z & 0\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Rotations about the principal axes (angle \(\alpha\) in radians):
$$
R_x(\alpha)=
\begin{pmatrix}
1 & 0 & 0 & 0\\[4pt]
0 & \cos\alpha & -\sin\alpha & 0\\[4pt]
0 & \sin\alpha & \cos\alpha & 0\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
$$
R_y(\alpha)=
\begin{pmatrix}
\cos\alpha & 0 & \sin\alpha & 0\\[4pt]
0 & 1 & 0 & 0\\[4pt]
-\sin\alpha & 0 & \cos\alpha & 0\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
$$
R_z(\alpha)=
\begin{pmatrix}
\cos\alpha & -\sin\alpha & 0 & 0\\[4pt]
\sin\alpha & \cos\alpha & 0 & 0\\[4pt]
0 & 0 & 1 & 0\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Rotation about an arbitrary unit axis \(\mathbf{u}=(u_x,u_y,u_z)\) is built with Rodrigues’ formula for the \(3\times3\) block and then embedded into a \(4\times4\) matrix. Define the skew matrix
$$
[\mathbf{u}]_{\times}=
\begin{pmatrix}
0 & -u_z & u_y\\[4pt]
u_z & 0 & -u_x\\[4pt]
-u_y & u_x & 0
\end{pmatrix},
$$
then the \(3\times3\) rotation block is
$$
R_3(\alpha,\mathbf{u}) = \cos\alpha\,I_{3} +
$$
$$
(1-\cos\alpha)\,\mathbf{u}\mathbf{u}^T + \sin\alpha\,[\mathbf{u}]_{\times}.
$$
Embed into \(4\times4\):
$$
R_{\mathbf{u}}(\alpha)=
\begin{pmatrix}
R_3(\alpha,\mathbf{u}) & \mathbf{0}\\[4pt]
\mathbf{0}^T & 1
\end{pmatrix}.
$$
Composition and order
Given transforms \(M_1, M_2, \dots, M_n\) listed in the order you intend them to be applied (first \(M_1\), then \(M_2\), etc.), the combined matrix is
$$
M_{\mathrm{total}} = M_n \cdot M_{n-1} \cdots M_2 \cdot M_1.
$$
Matrix multiplication is not commutative: changing the order changes the result. You may write composition either in listed order or in reverse list order depending on your workflow convention—just be consistent about which convention you use when applying \(M_{\mathrm{total}}\) to points.
Local to global and global to local
Convert a local point to global:
$$
p’ = M_{\mathrm{total}}\,p.
$$
Recover local coordinates from a global point:
$$
p = M_{\mathrm{total}}^{-1}\,p’.
$$
If \(M_{\mathrm{total}}\) is singular (non-invertible) the inverse does not exist; handle such cases explicitly in your tool and report an error.
Example 1 — translate(3, −2, 0.75) then rotateZ(25°)
Translation matrix:
$$
T=
\begin{pmatrix}
1 & 0 & 0 & 3\\[4pt]
0 & 1 & 0 & -2\\[4pt]
0 & 0 & 1 & 0.75\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Rotation about \(z\) by \(25^\circ\) (\(\alpha=25^\circ\), \(\cos\alpha\approx0.906,\ \sin\alpha\approx0.422\)):
$$
R_z(25^\circ)\approx
\begin{pmatrix}
0.906 & -0.422 & 0 & 0\\[4pt]
0.422 & 0.906 & 0 & 0\\[4pt]
0 & 0 & 1 & 0\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Apply translation first, then rotation, so
$$
M_{\mathrm{total}} = R_z(25^\circ)\,T \approx
$$
$$
\approx \begin{pmatrix}
0.906 & -0.422 & 0 & 3.564\\[4pt]
0.422 & 0.906 & 0 & -0.544\\[4pt]
0 & 0 & 1 & 0.75\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Transform the point
$$
p=\begin{pmatrix}1\\0\\0\\1\end{pmatrix}
$$
First \(T p=(4,-2,0.75,1)^T\). Then
$$
p’ = R_z(25^\circ)\,T p \approx
\begin{pmatrix}
4.470\\[4pt]
-0.122\\[4pt]
0.75\\[4pt]
1
\end{pmatrix}
$$
Example 2 — rotate about axis (2,1,0) by 60° then scale by (1.5, 0.8, 1)
Normalize axis \(\mathbf{u}=(2,1,0)\):
$$
\|\mathbf{u}\|=\sqrt{5}\approx2.236,
$$
$$
\hat{\mathbf{u}}=\frac{\mathbf{u}}{\|\mathbf{u}\|}\approx(0.894,\;0.447,\;0).
$$
Using Rodrigues’ formula with \(\alpha=60^\circ\) (\(\cos=0.5,\ \sin\approx0.866\)), the \(3\times3\) rotation block is
$$
R_3(60^\circ,\hat{\mathbf{u}})\approx
$$
$$
\approx \begin{pmatrix}
0.9 & 0.2 & 0.387\\[4pt]
0.2 & 0.6 & -0.774\\[4pt]
-0.387 & 0.774 & 0.5
\end{pmatrix}
$$
Scale matrix:
$$
S=\mathrm{diag}(1.5,\;0.8,\;1).
$$
If you apply rotation first and then scale, the \(3\times3\) upper-left block of the total transform is
$$
M_{3\times3} = S\cdot R_3 \approx
$$
$$
\approx \begin{pmatrix}
1.35 & 0.30 & 0.580\\[4pt]
0.16 & 0.48 & -0.619\\[4pt]
-0.387 & 0.774 & 0.5
\end{pmatrix},
$$
and the full \(4\times4\) matrix is
$$
M_{\mathrm{total}} \approx
\begin{pmatrix}
1.35 & 0.30 & 0.580 & 0\\[4pt]
0.16 & 0.48 & -0.619 & 0\\[4pt]
-0.387 & 0.774 & 0.5 & 0\\[4pt]
0 & 0 & 0 & 1
\end{pmatrix}
$$
Apply this to \(p=(0,1,0,1)^T\): first rotation gives
$$
R_3\begin{pmatrix}0\\1\\0\end{pmatrix}\approx
\begin{pmatrix}
0.2\\[4pt]
0.6\\[4pt]
0.774
\end{pmatrix},
$$
then scaling yields
$$
p’ = M_{\mathrm{total}}\,p \approx
\begin{pmatrix}
0.3\\[4pt]
0.48\\[4pt]
0.774\\[4pt]
1
\end{pmatrix}
$$
Inputs
- Points listed one per line as x y z separated by comma or space.
- Transform sequence where each item is translate, rotateX, rotateY, rotateZ, rotate axis, or scale with numeric parameters.
- Order mode choose list order or reverse order.
- Direction choose local to global or global to local to control inversion.
Outputs
- Readable final 4×4 matrix displayed in four rows.
- Transformed coordinates for every input point available in plain text and CSV export.
- Invertible flag for the matrix before applying inverse.
- Quick copy of the matrix to clipboard for pasting into code or CAD tools.
Practical recommendations and advanced notes
- Keep transforms in TRS form translation rotation scale and regenerate M_total from parameters rather than multiplying matrices repeatedly to avoid floating point drift.
- For rotations use quaternions when interpolating or animating to avoid gimbal lock and to produce smooth slerp interpolation. Convert matrices to quaternions after orthonormalizing the 3×3 block.
- If you only invert a rigid transform without scale use transpose of the rotation block and negate rotated translation for a fast exact inverse.
- When nonuniform scale or shear is present perform TRS decomposition or SVD before inversion to avoid errors; SVD yields a stable pseudo inverse for near singular cases.
- Watch storage convention row major versus column major and whether matrices multiply on the left or right in your engine. Test by applying the matrix to basis vectors e1 e2 e3 to confirm expected axes and handedness.
- Precompute combined matrices on CPU and upload once to GPU for many points. Use typed arrays and optimized libraries such as gl-matrix for performance.
- To detect numerical problems compute condition number of the linear 3×3 part. High condition numbers indicate unstable inversion. If condition number is poor apply regularization or work in higher precision if available.
Debug checklist
- Apply M_total to origin and unit axes then verify positions and orientations.
- Roundtrip test apply inverse to transformed points and compare with original points within tolerance.
- Check for NaN or infinite values early they indicate invalid input such as nonnumeric parameters or division by zero.
- Confirm angle units degrees or radians and conversion is applied consistently.
#️⃣ Building a single 4×4 matrix from a sequence of elementary transforms simplifies per-point computation and clarifies the effect of operation order. This coordinate transform utility helps validate and debug transform stacks and produces reproducible matrices for CAD pipelines, game engines, and simulation tasks.
Recommended reading
- Ken Shoemake and Tom Duff, 3D Math Primer for Graphics and Game Development
- Eberly, Geometric Tools for Computer Graphics
- Foley, van Dam, Feiner, Hughes, Computer Graphics Principles and Practice
- Kuffner, Robotics, Vision and Control practical matrix methods
- Horn, Robot Vision and Matrix Computation






