Download presentation
1
Lecture Notes: Computer Graphics
2
Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it and rotate it
3
Transformation Two complementary views
Geometric trans: Object is transformed relative to a stationary coordinate system Coordinate trans: Object is held stationary while the coordinate system is transformed Ex: moving an automobile against a scenic background Move the auto and keep the background fixed (GT) Keep the car fixed and move the background (CT)
4
Basic 2D Geometric Transformations
Four basic types Translation Scaling Rotation Shear (possible using a combination of rotation and scaling)
5
Translation xnew = xold + tx ynew = yold + ty
Simply moves an object from one position to another xnew = xold + tx ynew = yold + ty Note: House shifts position relative to origin y x 1 2 3 4 5 6 7 8 9 10
6
Scaling xnew = Sx × xold ynew = Sy × yold
Scalar multiplies all coordinates WATCH OUT: Objects grow and move! xnew = Sx × xold ynew = Sy × yold Note: House shifts position relative to origin y x 1 2 3 4 5 6 7 8 9 10
7
Rotation xnew = xold × cosθ – yold × sinθ
Rotates all coordinates by a specified angle xnew = xold × cosθ – yold × sinθ ynew = xold × sinθ + yold × cosθ Points are always rotated about the origin y 6 5 4 3 2 1 x 1 2 3 4 5 6 7 8 9 10
8
Shear Along X-axis Along Y-axis
9
Basic 2D Geometric Transformations
Translation Scale Rotation Shear
10
Transformation and Matrix Multiplication
Recall how matrix multiplication takes place:
11
Matrix Representation
Represent a 2D Transformation by a Matrix Apply the Transformation to a Point Transformation Matrix Point
12
Matrix Representation
Transformations can be combined by matrix multiplication Transformation Matrix Matrices are a convenient and efficient way to represent a sequence of transformations
13
2×2 Matrices What types of transformations can be represented with a 2×2 matrix? 2D Identity 2D Scaling
14
2×2 Matrices What types of transformations can be represented with a 2×2 matrix? 2D Rotation 2D Shearing
15
2×2 Matrices 2D Mirror over Y axis
What types of transformations can be represented with a 2×2 matrix? 2D Mirror over Y axis 2D Mirror over (0,0)
16
2×2 Matrices 2D Translation
What types of transformations can be represented with a 2×2 matrix? 2D Translation NO!! Only linear 2D transformations can be Represented with 2x2 matrix
17
Homogeneous Coordinates
A point (x, y) can be re-written in homogeneous coordinates as (xh, yh, h) The homogeneous parameter h is a non-zero value such that: We can then write any point (x, y) as (hx, hy, h) We can conveniently choose h = 1 so that (x, y) becomes (x, y, 1)
18
Homogeneous Coordinates
Add a 3rd coordinate to every 2D point (x, y, w) represents a point at location (x/w, y/w) (x, y, 0) represents a point at infinity (0, 0, 0) is not allowed y 2 (2, 1, 1) or (4, 2, 2) or (6, 3, 3) 1 x 1 2 Convenient Coordinate System to Represent Many Useful Transformations
19
Why Homogeneous Coordinates?
Mathematicians commonly use homogeneous coordinates as they allow scaling factors to be removed from equations We will see in a moment that all of the transformations we discussed previously can be represented as 3*3 matrices Using homogeneous coordinates allows us use matrix multiplication to calculate transformations – extremely efficient!
20
Homogeneous Translation
The translation of a point by (dx, dy) can be written in matrix form as: Representing the point as a homogeneous column vector we perform the calculation as:
21
Homogenous Coordinates
To make operations easier, 2-D points are written as homogenous coordinate column vectors Translation: Scaling:
22
Basic 2D Transformations
Basic 2D transformations as 3x3 Matrices Translate Scale Rotate Shear
23
Combining Transformations
A number of transformations can be combined into one matrix to make things easy Allowed by the fact that we use homogenous coordinates Imagine rotating a polygon around a point other than the origin Transform to centre point to origin Rotate around origin Transform back to centre point
24
Matrix Composition Transformations can be combined by matrix multiplication Efficiency with premultiplication Matrix multiplication is associative
25
Combining Transformations (cont…)
1 2 3 4
26
Combining Transformations (cont…)
The three transformation matrices are combined as follows REMEMBER: Matrix multiplication is not commutative so order matters
27
Matrix Composition Rotate by around arbitrary point (a,b)
Scale by sx, sy around arbitrary point (a,b) (a,b) (a,b)
28
Inverse Transformations
Transformations can easily be reversed using inverse transformations
29
Basic 2D Coordinate Transformations
Translation Scale Rotation Shear ??
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.