The Order of Transformations
Moving an object sideways and then rotating it differs from rotating first and moving afterward. Transformation order determines the final position.
Check with numbers
A counterclockwise 90-degree rotation around the origin maps (x,y) to (-y,x). Combine it with moving point (1,0) two units along x.
def rotate90(point):
x, y = point
return (-y, x)
def move_right(point):
x, y = point
return (x + 2, y)
print(rotate90(move_right((1, 0))))
print(move_right(rotate90((1, 0))))
The outputs are (0, 3) and (2, 1). In the first case, the translated point rotates around the origin. In the second, the rotated point moves right.
Why use matrices?
Matrices represent translation, rotation, and scaling and let several transformations be combined by multiplication. Homogeneous coordinates extend 2D points to (x,y,1) and 3D points to (x,y,z,1), allowing translation to use matrix multiplication too.
With column vectors, p' = T R p applies R first and T second. Row-vector conventions change the written order. Check the convention used by your source or API.
To rotate around an object’s own center, move that center to the origin, rotate, then translate back.
Check your understanding
If you double every position coordinate around the origin, does an object’s center move too?
Show explanation
Yes, unless it is at the origin. To scale while fixing its center, translate to the origin, scale, and translate back, just as for rotation.