Unformatted text preview:

CSCE 441 Computer Graphics: 2D Transformations2D TransformationsSlide 32D TransformationPoint RepresentationTranslation3x3 2D Translation MatrixSlide 82D RotationSlide 10Slide 11Slide 12Slide 133x3 2D Rotation MatrixSlide 152D ScalingSlide 173x3 2D Scaling MatrixPut it all togetherOr, 3x3 Matrix RepresentationsWhy Use 3x3 Matrices?Slide 22ShearingSlide 24ReflectionSlide 26Slide 27Reflection about X-axisSlide 29Reflection about Y-axisSlide 31What’s the Transformation Matrix?Slide 33Slide 34Arbitrary Rotation CenterSlide 36Slide 37Slide 38Slide 39Scaling RevisitArbitrary Scaling PivotSlide 42Slide 43Slide 44Affine TransformationSlide 46Slide 47Composing TransformationSlide 49Composing TransformationTransformation Order Matters!Finding Affine TransformationsSlide 53Slide 54Slide 55Slide 56Slide 57Slide 58Next Lecture1CSCE 441 Computer Graphics:2D TransformationsJinxiang Chai22D Transformationsxyxyxy32D TransformationsxyxyxyApplications:- Animation- Image/object manipulation- Viewing transformation- etc.42D Transformation•Required readings: HB 5-1 to 5-5, 5-8 •Given a 2D object, transformation is to change the object’s –Position (translation)–Size (scaling)–Orientation (rotation)–Shapes (shear)•Apply a sequence of matrix multiplications to the object vertices5Point Representation•We can use a column vector (a 2x1 matrix) to represent a 2D point x y•A general form of linear transformation can be written as: x’ = ax + by + c OR y’ = dx + ey + f X’ a b c xY’ = d e f * y1 0 0 1 16Translation•Re-position a point along a straight line •Given a point (x,y), and the translation distance (tx,ty)The new point: (x’, y’) x’ = x + tx y’ = y + ty (x,y)(x’,y’)OR P’ = P + T where P’ = x’ p = x T = tx y’ y ty txty73x3 2D Translation Matrix x’ = x + tx y’ y ty Use 3 x 1 vector x’ 1 0 tx x y’ = 0 1 ty * y1 0 0 1 1 Note that now it becomes a matrix-vector multiplication8Translation•How to translate an object with multiple vertices? Translate individualvertices92D Rotation•Default rotation center: Origin (0,0) 0 Rotate counter clockwise Rotate clockwise 10(x,y) (x’,y’) (x,y) -> Rotate about the origin by (x’, y’)How to compute (x’, y’) ?r2D Rotation11(x,y) (x’,y’) (x,y) -> Rotate about the origin by (x’, y’)How to compute (x’, y’) ?x = r cos () y = r sin ()rx’ = r cos () y’ = r sin ()2D Rotation122D Rotation(x,y) (x’,y’) rx = r cos () y = r sin ()x’ = r cos () y = r sin ()x’ = r cos () = r cos() cos() – r sin() sin() = x cos() – y sin() y’ = r sin () = r sin() cos() + r cos()sin() = y cos() + x sin()132D Rotation(x,y) (x’,y’) rx’ = x cos() – y sin() y’ = y cos() + x sin() Matrix form?x’ cos() -sin() x y’ sin() cos() y=3 x 3?143x3 2D Rotation Matrixx’ cos() -sin() x y’ sin() cos() y=(x,y) (x’,y’) rx’ cos() -sin() 0 x y’ sin() cos() 0 y1 0 0 1 1=15How to rotate an object with multiple vertices? Rotate individualVertices 2D Rotation162D Scaling Scale: Alter the size of an object by a scaling factor (Sx, Sy), i.e. x’ = x . Sx y’ = y . Sy x’ Sx 0 xy’ 0 Sy y=(1,1)(2,2)Sx = 2, Sy = 2 (2,2)(4,4)172D Scaling (1,1)(2,2)Sx = 2, Sy = 2 (2,2)(4,4) Not only the object size is changed, it also moved!!  Usually this is an undesirable effect  We will discuss later (soon) how to fix it183x3 2D Scaling Matrixx’ Sx 0 xy’ 0 Sy y=x’ Sx 0 0 x y’ = 0 Sy 0 * y1 0 0 1 119Put it all together •Translation:•Rotation:•Scaling:yxttyxyxyxttyxcossinsincosyxyxttssyx0020Or, 3x3 Matrix Representations•Translation: •Rotation: •Scaling: x’ 1 0 tx x y’ = 0 1 ty * y1 0 0 1 1x’ cos() -sin() 0 x y’ sin() cos() 0 * y1 0 0 1 1=x’ Sx 0 0 x y’ = 0 Sy 0 * y1 0 0 1 1Why use 3x3 matrices?21Why Use 3x3 Matrices?•So that we can perform all transformations using matrix/vector multiplications•This allows us to pre-multiply all the matrices together •The point (x,y) needs to be represented as (x,y,1) -> this is called Homogeneous coordinates!•How to represent a vector (vx,vy)?22Why Use 3x3 Matrices?•So that we can perform all transformations using matrix/vector multiplications•This allows us to pre-multiply all the matrices together •The point (x,y) needs to be represented as (x,y,1) -> this is called Homogeneous coordinates!•How to represent a vector (vx,vy)? (vx,vy,0)23Shearing•Y coordinates are unaffected, but x coordinates are translated linearly with y•That is:–y’ = y –x’ = x + y * h x 1 h 0 xy = 0 1 0 * y1 0 0 1 124x 1 0 0 xy = g 1 0 * y1 0 0 1 1 A 2D rotation is three shearsShearing will not change the area of the objectAny 2D shearing can be done by a rotation, followed by a scaling, and followed by a rotationInteresting Facts: Shearing in Y25Reflection26Reflection27Reflection28Reflection about X-axis29Reflection about X-axisx 1 0 0 xy = 0 -1 0 * y1 0 0 1 130Reflection about Y-axis31Reflection about Y-axisx -1 0 0 xy = 0 1 0 * y1 0 0 1 132What’s the Transformation Matrix?33What’s the Transformation Matrix?x -1 0 0 xy = 0 -1 0 * y1 0 0


View Full Document

TAMU CSCE 441 - lecture6

Documents in this Course
Load more
Download lecture6
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lecture6 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lecture6 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?