1 / 17

3.1 2D Geometry - points and polygons

3.1 2D Geometry - points and polygons. A point in 2D is represented by two real numbers (X,Y). Y. X. A line segment is represented by its two end points (X 1 ,Y 1 ) (X 2 ,Y 2 ), or a 2x2 matrix [ ]. X 1 Y 1 X 2 Y 2. Y. X. A polygon is represented by an list of

mippolito
Télécharger la présentation

3.1 2D Geometry - points and polygons

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3.1 2D Geometry - points and polygons A point in 2D is represented by two real numbers (X,Y) Y X A line segment is represented by its two end points (X1,Y1) (X2,Y2), or a 2x2 matrix [ ] X1 Y1 X2 Y2 Y X

  2. A polygon is represented by an list of points (X1,Y1), (X2,Y2), ..... (Xn,Yn) or a n x 2 matrix [ ] For example, a triangle is represent by [ ] X1 Y1 : : Xn Yn X1 Y1 X2 Y2 X3 Y3 Y X

  3. Y (2,4) 2 (6,2) (2,2) 1 X 8 2 1 3.2 Object transformation and Coordinates System transformation Object transformation is different from the coordinates system transformation

  4. Object Transformation Y Scale (1/2) about the origin X Y Translation (2,1) X Rotation (p/2) counter clock wise about the origin Y X

  5. Coordinates system transformation Y* Scale (1/2) about the origin X* 2 3 1 Y Translation (2,1) X Y Rotation (p/2) counter clock wise about the origin X If not described explicitly, transformation always means object transformation

  6. There are 3 "basic" transformations: (1) Translation (2) Scaling (3) Rotation A series of transformations can be combined (concatenated) into one. (1) Translation : T(Tx, Ty) 2D Translations 3.3 Y (x',y') Ty (x,y) Tx X

  7. Y Y (x',y') (x,y) X X (2) Scaling (about the origin) : S(Sx, Sy) • What about "Mirror Images"? • How do we avoid distortion? • What happens when the scale factor equal to zero? S(-2, -1)

  8. (3) Rotation (about the origin • counterclockwise) : • x = R cos a • y = R sin a • x' = R cos(a + q) = R(cos a cos q - sin a sin q) • y' = R sin(a + q) = R(sin a cos q + cos a sinq) • So, • x ' = xcosq - ysinq • y ' = xsinq + ycosq Y (x',y') (x,y) q a X

  9. Concatenation -- A series of transformations can be combined (concatenated) into one. Example: scaling about arbitrarypoint. 1. Translate so that point (a,b) becomes the temporary origin: x1 = x - a y1 = y - b 2. Scale to the correct size: x2 = Sx*x1y2 =Sy*y1 3. Translate again to restore the coordinates of (a,b): x3 = x2 + a y3 = y2 + b Y (x,y) (a,b) X

  10. Algebraic representations for transformations are very limited: (1) A special procedure is need for each basic transformation and other known concatenated forms. (2) It is difficult to provide general transformation capabilities in algebraic form in the computer. (3) How can one find the inverse of a concatenated equation (to restore the original position, for example)?

  11. Let the point (x,y) be a row vector [x y]: x' = ax + by and y' = cx + dy can be expressed in the matrix equation: [x' y'] = [x y] * [ ]2x2 Let P' = [x' y'] and P = [x y], this becomes the matrix equation: P' = P * T where P' =[x' y'] , P = [x y] , T = Consider three basic transformations, can we find a "T" for each? • What about translations? X'=X+Tx, Y'=Y+Ty No, P' =[x' y']=[x y] []+[Tx Ty]=P*T+Q • What about scaling? X'=Sx*X, Y'=Sy*Y Yes, P' =[x' y']=[x y] [] =P*T • What about rotation? x'=xcosq-ysinq, y'=xsinq+ycosq Yes, P' =[x' y']=[x y] [] a c b d [ ] 1 0 0 1 Sx 0 0 Sy cosq sinq -sinq cosq

  12. 3.4 Homogeneous Coordinates Let the point (x,y) be a row vector [x y 1]: x' = ax + by + e and y' = cx + dy + f can be expressed in the matrix equation: [x' y' 1] = [x y 1] [ ]3x3 This becomes the matrix equation P' = P * T where P'=[x' y' 1], P= [x y 1], T= [ ] Now, can we find a "T" for each transformation? • What about translations? Yes, T= [ ] • What about scaling? Yes, T= [ ] • What about rotation?Yes, T= [ ]

  13. (x', y') = (0, 1) (x, y) = (1, 0) Y (2,2) A (4,1) C B (2,1) X To check, what should the matrix be if we: (1) translate by (0,0) ? P'=P*[ ]=P*[ ]=P (2) scale by (1,1) ? P'=P*[ ]=P*[ ]=P (3) rotate by 0 o ? P'=P*[ ]=P*[ ]=P (4) rotate by 90o ? P'=[x' y' 1]=[x y 1] [] =[1 0 1]*[]=[0 1 1] Draw the pictures and find the new vertices of the triangle for the following transformations (See the figure below) :

  14. Y (2,2) A C (4,1) (2,1) B X Y (2,2) A C (4,1) (2,1) B X Y (2,2) A C (4,1) (2,1) B X (5) translate A by (2,1). (6) translate A by (-2,1). (7) scale A by (2,1). (8) scale A by (-1,1). Y (2,2) A C (4,1) (2,1) B X

  15. Y (2,2) A C (4,1) (2,1) B X Y (2,2) A C (4,1) (2,1) B X Y (2,2) A C (4,1) (2,1) B X (9) scale A by (1,0). (10) scale A by (0,0). (11) rotate A by 0o. (12) rotate A by 90o . Y (2,2) A C (4,1) (2,1) B X

  16. Y (x, y) (a,b) X 3.5 Composite 2D Transformation Concatenation is easy now. Consider our scaling example: Example: We want to reduce the size or the box, without changing the position of point (a, b) Functional form and matrix form for each transformations: (1) translate: T(-a,-b) (2) scale : S(Sx,Sy) (3) translate: T(a,b)

  17. Combining the matrix equations: P3 =P2* T (-a,-b)=(P1*S(Sx, Sy) )*T(a, b) =P*T(-a, -b)*S(Sx, Sy)*T(a, b) Multiply the matrices : Now, the matrix equation is : or, in algebraic form : Thus, a single 3x3 matrix can represent any combination of basic transformations in a simple form.

More Related