2D Geometry - points and polygons

Slides:



Advertisements
Similar presentations
8. 2D Coordinate Operations Assoc.Prof.Dr. Ahmet Zafer Şenalp Mechanical Engineering Department Gebze.
Advertisements

Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
Course Website: Computer Graphics 3: 2D Transformations.
Math for CSLecture 11 Mathematical Methods for Computer Science Lecture 1.
Transformations Review. Recall: Types of Transformations Translations Reflections Rotations.
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
Lecture Notes: Computer Graphics.
2D Geometric Transformations
CGPage: 1 東吳資訊科學 江清水 3.1 2D Geometry - points and polygons X Y A point in 2D is represented by two real numbers (X,Y) A line segment is represented by.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
CS559: Computer Graphics Lecture 8: Warping, Morphing, 3D Transformation Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
WARM UP: Describe in words how to rotate a figure 90 degrees clockwise.
CGPage: 1 東吳資訊管理 江清水 Computer Game : Basic 1.Computer Graphics and Its application 2.2D Coordinate Geometry 3.1 2D geometry -- points and polygons 3.2.
Two-Dimensional Geometric Transformations A two dimensional transformation is any operation on a point in space (x, y) that maps that point's coordinates.
2D Geometric Transformation Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
 An image is the new figure, and the preimage is the original figure  Transformations-move or change a figure in some way to produce an image.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
2.4 Modeling Motion in Matrices Objectives: 1.Use matrices to determine the coordinates of polygons under a given transformation.
Computer Graphic 2 D Transformation.
CSCE 441 Computer Graphics: 2D Transformations
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
CPT450 – Computer Graphics
Computer Graphics 2D Transformations
CS5500 Computer Graphics March 6, 2006.
Modeling Transformations
Geometric Transformations
Computer Graphics 3: 2D Transformations
Transformations Objectives
Right-handed Coordinates System
Geometric Transformations Hearn & Baker Chapter 5
2D Transformations By: KanwarjeetSingh
2D Geometric Transformations
Computer Graphics Transformations.
Computer Graphics 3: 2D Transformations
Computer Graphics Lecture 18 3-D Transformations-II Taqdees A
3D Geometric Transformations
Chapter 5 2-D Transformations.
Computer Graphics Transformations.
Introduction to Computer Graphics CS 445 / 645
Lecture 7 Geometric Transformations (Continued)
2D Transformations y y x x y x.
Image Warping (Szeliski Sec 2.1.2)
Image Warping (Szeliski Sec 2.1.2)
Computer Graphics Transformations
Three-Dimensional Graphics
Line and Character Attributes 2-D Transformation
Linear Algebra Review.
Image Warping : Computational Photography
With an immediate use for it
Geometric Transformations
Chapter IV Spaces and Transforms
[ ] 5.2 3D Geometry We can use the way to represent 3D points
Image Warping : Computational Photography
Algebraic Representations of Transformations
Three-Dimensional Graphics
Transformations Ed Angel
Image Warping (Szeliski Sec 2.1.2)
Plane 2D GEOMETRICAL TRANSFORMATIONS Example: J2_0_2DTransform
Transformations Ed Angel Professor Emeritus of Computer Science
CS1550 Fundamentals For Computer Graphics Transformations-2
Isaac Gang University of Mary Hardin-Baylor
Rendering – Matrix Transformations and the Graphics Pipeline
Presentation transcript:

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

[ ] 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

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

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

Coordinates system transformation Scale (1/2) about the origin X* 1 2 3 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

2D Translations 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) Y (x',y') Ty (x,y) Tx 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? X Y (x,y) (x',y') S(-2, -1)

(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

Example: scaling about arbitrary point. Concatenation -- A series of transformations can be combined (concatenated) into one. Example: scaling about arbitrary point. 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*x1 y2 = Sy*y1 3. Translate again to restore the coordinates of (a,b): x3 = x2 + a y3 = y2 + b Y Hence, we can concatenate any number of basic transformations into one set of equations, eliminating the intermediate results -- which would have required extra data storage and computation. (x,y) (a,b) X

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)?

[ ] 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

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= [ ]

To check, what should the matrix be if we: (1) translate by (0,0) ? P'=P*[ ]=P*[ ]=P (2) scale by (1,1) ? (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) : (x, y) = (1, 0) (x', y') = (0, 1) X Y (2,2) (2,1) (4,1) A B C

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

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

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) Composite 2D Transformation (a,b) Y (x, y) X

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.