CS1550 Fundamentals For Computer Graphics Transformations-2 Sumanth Shankar California State University, Los Angeles
Homogeneous Coordinates Homogeneous coordinates define a point in a plane using three coordinates instead of two. For a point P with coordinates (X, Y) there exists homogeneous point (x, y, t) such that X = x/t and Y = y/t. For example the point(3, 4) has homogeneous coordinates (6, 8, 2).
2D Translation The matrix notation for 2D translation is 𝑥′ 𝑦′ 1 = 1 0 𝑡𝑥 0 1 𝑡𝑦 0 0 1 * 𝑥 𝑦 1 x’ = x + tx y’ = y + ty
2D Scaling The matrix notation for 2D scaling is 𝑥′ 𝑦′ 1 = 𝑠𝑥 0 0 0 𝑠𝑦 0 0 0 1 * 𝑥 𝑦 1 Scaling is relative to the origin. It means the point (0, 0) remains (0, 0) all other points move away from the origin
2D Scaling To scale relative to another point (px, py) we first subtract (px, py) from (x, y) and add (px, py) back to (x, y). x’ = sx(x – px) + px y’ = sy(y – py) + py x’ = sx x + px(1 – sx) y’ = sy y + py(1 – sy)
2D Scaling In matrix form it is represented using 𝑥′ 𝑦′ 1 = 𝑠𝑥 0 𝑝𝑥(1 −𝑠𝑥) 0 𝑠𝑦 𝑝𝑦(1 −𝑠𝑦) 0 0 1 * 𝑥 𝑦 1
2D Reflections To make reflection about the vertical axis when x = 1, we subtract 1 from the x coordinate, then we reverse the sign of the modified x coordinate and finally we add 1 to the x coordinate. x1 = x – 1 x2 = -(x – 1) x’ = -(x – 1) + 1 y’ = y
2D Reflections In general when for ax the following transformation is required. x’ = -(x – ax) + ax = -x + 2ax y’ = y In matrix form 𝑥′ 𝑦′ 1 = −1 0 2𝑎𝑥 0 1 0 0 0 1 * 𝑥 𝑦 1
2D Reflections Similarly when for ay the following transformation is required. x’ = x y’ = -(y – ay) + ay = -y + 2ay In matrix form 𝑥′ 𝑦′ 1 = 1 0 0 0 −1 2𝑎𝑦 0 0 1 * 𝑥 𝑦 1