A 3×3 matrix can rotate and scale a point, but it can't move one — every linear map pins the origin in place. Adding a fourth coordinate fixes that: write the point as [x, y, z, 1] and translation becomes just another matrix multiply.
Task: write apply_transform(matrix, points) where matrix is 4×4 and points is a list of [x, y, z]. Return the transformed points as [x, y, z], rounded to 4 decimal places.
[x, y, z, 1] before multiplying.w (the fourth), then drop it. If w is 0, leave the components as they are.That divide is the whole reason perspective projection works. An affine transform always leaves
w = 1and the division does nothing — but a projection matrix setswproportional to depth, so the same line of code is what makes distant things smaller.