- 2d Transformations
→ Rotations
→ Translations
→ Scaling
- general transformations:
→ maps points to other points and vectors to other vectors by a function T
- Affine transmorations
→ line preserving: lines are still lines after the transformation (they don't curve)
- Translation
→ every point is displaced by the same vector
- Rotation
→ every point is rotated around some pivot point
⇒ does not have to be the center of the object itself
- Scaling
→ squash or stretch an object in one direction (non uniform) or both directions (uniform)
Representation of points
- we can represent a 2d point P as a column vector
- vector can also be a column vector
- P' = P + v (translation)
- Scaling
→ Px' = sxPx
→ Py' = syPy
→ P' = [[sx, 0][0,sy]] [Px, Py]
- Rotation
→ Px' = PxcosTheta - PysinTheta
→ Py' = PxsinTheta + PycosTheta
→ trigonometric compound angle identities
→ P' = [[cosTheta, -sinTheta][sinTheta, cosTheta]] [Px, Py]
Inverse tranformations
- T-1(vx,vy) = T(-vx,-vy)
- R-1(theta) = R(-theta)
- scale
Concatenating multiple tranformations
- P' = T(R(S P))) Scale, rotate, then translate
- under thehood this is all matrices and we have to worry about the order in which we perform the transformations
- Problem:
→ translation is not a matrix multiplication, its an addition
→ it would be cleaner if everything was a matrix multiplication
→ we also dont only have one point, we have the entire object
- solution:
→ We can augment our points and vectors.
→ if its a vector, it is [vx, vy, 0] and point becomes [Px, Py, 1]
→ we use a 3 component homogeneous coordinate representation for points and vectors in 2d
→ vector + point should give a new point
→ [vx vy 0] + [px py 1] = [vx + px , vy + py, 0 + 1]
→ point - point = vector
→ now we can represent the translation P + v 1using a 3x3 matrix T in 2D homogenous coordinates
→ P' = [[1,0,vx][0,1,vy][0,0,1] [ Px, Py, 1 ]
→ we habve to change our scale and rotate matrix multiplication to match
- now we can combine the three matrix multiplications into one matrix
→ P' = ( T R S ) P = M P Index