Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2004CS-321 Dr. Mark L. Hornick 1 2-D Transformations World Coordinates Local/Modelling Coordinates x y Object descriptions Often defined in model.

Similar presentations


Presentation on theme: "Fall 2004CS-321 Dr. Mark L. Hornick 1 2-D Transformations World Coordinates Local/Modelling Coordinates x y Object descriptions Often defined in model."— Presentation transcript:

1 Fall 2004CS-321 Dr. Mark L. Hornick 1 2-D Transformations World Coordinates Local/Modelling Coordinates x y Object descriptions Often defined in model coordinates Must be mapped to world coordinates Groups of objects are combined; complete image is formed by combining primitives

2 Fall 2004CS-321 Dr. Mark L. Hornick 2 2-D Transformations World Coordinates Local/Modelling Coordinates x y Problem statement: Convert points from coordinates in one system to a second coordinate system

3 Fall 2004CS-321 Dr. Mark L. Hornick 3 2-D Transformations x1x1 y2y2 x2x2 y1y1 v1v1 v2v2 p First, consider the case where two coordinate systems are offset by a pure translation Definitions v 2 – vector from origin of coordinate system xy 2 to a point on the object has scalar components (v 2x,v 2y ) v 1 – vector from origin of coordinate system xy 1 to a point on the object has scalar components (v 1x,v 1y ) p – vector from origin of coordinate system xy 1 to the origin of xy 2 has scalar components (p x,p y )

4 Fall 2004CS-321 Dr. Mark L. Hornick 4 2-D Transformations: Translation x1x1 y2y2 x2x2 y1y1 v1v1 v2v2 p Using vector math: v 1 = p + v 2 In terms of scalar components: v 1x = p x + v 2x v 1y = p y + v 2y And conversely: v 2 = v 1 – p v 2x = v 1x - p x v 2y = v 1y - p y

5 Fall 2004CS-321 Dr. Mark L. Hornick 5 2-D Transformations: Rotation x1x1 y1y1 v1v1 y2y2 x2x2 v2v2 Now consider the case of a pure rotation of one coordinate system with respect to the other A simple case is rotation by 180 degrees In this case, vectors v 1 and v 2 are coincident (they lie on top of each other), but they have opposite sense, that is: v 1 = -v 2 In terms of scalar components: v 1x = - v 2x v 1y = - v 2y x1x1 y1y1 v1v1 y2y2 x2x2 v2v2

6 Fall 2004CS-321 Dr. Mark L. Hornick 6 2-D Transformations: Rotation x1x1 v1v1 y2y2 x2x2 v2v2 Next, consider the general case of a pure rotation of one coordinate system with respect to the other, but through an arbitrary angle  x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  

7 Fall 2004CS-321 Dr. Mark L. Hornick 7 2-D Transformations: Rotation Using trigonometry, it can be shown that: In terms of scalar components: v 1x = v 2x cos  - v 2y sin  v 1y = v 2y cos  + v 2x sin  In vector terms: v 1 = v 2 cos  + (-v 2y,v 2y ) sin  But what vector is (-v 2y,v 2y )? It can be shown that x1x1 v1v1 y2y2 x2x2 v2v2 x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  

8 Fall 2004CS-321 Dr. Mark L. Hornick 8 2-D Transformations: Rotation Instead of using vector representation, these equations can also be cast in matrix form: x1x1 v1v1 y2y2 x2x2 v2v2 x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  

9 Fall 2004CS-321 Dr. Mark L. Hornick 9 2-D Transformations: Rotation Now that we have v 1 in terms of v 2, how do we express v 2 in terms of v 1 ? Where R(  ) -1 is the inverse of R(  ) x1x1 v1v1 y2y2 x2x2 v2v2 x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  

10 Fall 2004CS-321 Dr. Mark L. Hornick 10 2-D Transformations: Rotation To express v 2 in terms of v 1, we can think of xy 1 rotated through a negative angle  x1x1 v1v1 y2y2 x2x2 v2v2 x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  

11 Fall 2004CS-321 Dr. Mark L. Hornick 11 2-D Transformations: Rotation So the inverse R(  ) -1 is R(-  ) Note also that the inverse R(  ) -1 is simply the transpose of R(-  ) since the off-diagonal elements are swapped This is a property of special matrices called orthonormal matrices; Rotation matrices are orthonormal This makes it easy to find the inverse of a rotation matrix x1x1 v1v1 y2y2 x2x2 v2v2 x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  

12 Fall 2004CS-321 Dr. Mark L. Hornick 12 Combining Rotation and Translation The case of combined rotation and translation can be deconstructed into a pure rotation followed by a pure translation. The pure rotation transforms vector v 2 from coordinate frame xy 1 to vector v* 2 in frame xy* 2 The following pure translation transforms v* 2 from frame xy* 2 into vector v 1 in frame xy 1 x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  p y* 2 x* 2

13 Fall 2004CS-321 Dr. Mark L. Hornick 13 Combining Rotation and Translation The equations that describe this transformation are just the combination of those we have already seen: x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  p y* 2 x* 2

14 Fall 2004CS-321 Dr. Mark L. Hornick 14 Combining Rotation and Translation This equation can be recast using a mathematical trick: This is called a 3x3 homogeneous transformation matrix T ( ,p) x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  p y* 2 x* 2

15 Fall 2004CS-321 Dr. Mark L. Hornick 15 Combining Rotation and Translation T ( , p ) can be expressed in terms of submatrices as The inverse of T ( , p ) is given by x1x1 y1y1 v1v1 v2v2 y2y2 x2x2  p y* 2 x* 2


Download ppt "Fall 2004CS-321 Dr. Mark L. Hornick 1 2-D Transformations World Coordinates Local/Modelling Coordinates x y Object descriptions Often defined in model."

Similar presentations


Ads by Google