2D Transformation. Transformation changes an object’s: – Position(Translation) – Size(Scaling) – Orientation(Rotation) – Shape(Deformation) Transformation.

Slides:



Advertisements
Similar presentations
Computer Graphics: 2D Transformations
Advertisements

Today Composing transformations 3D Transformations
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
University of North Carolina at Greensboro
Geometric Transformations
1 ME 302 DYNAMICS OF MACHINERY Dynamic Force Analysis IV Dr. Sadettin KAPUCU © 2007 Sadettin Kapucu.
1 Computer Graphics Chapter 6 2D Transformations.
2D Geometric Transformations
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
1 Geometrical Transformation Tong-Yee Lee. 2 Modeling Transform Specify transformation for objects Allow definitions of objects in own coordinate systems.
Course Website: Computer Graphics 3: 2D Transformations.
2IV60 Computer Graphics 2D transformations
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.
CS 450: Computer Graphics 2D TRANSFORMATIONS
3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. 3D Transformation glVertex3f(x, y,z);
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformations Dr. Amy Zhang.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Lecture Notes: Computer Graphics.
Geometric Transformations Jehee Lee Seoul National University.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations Jehee Lee Seoul National University.
Matrices, Transformations and the 3D Pipeline Matthew Rusch Paul Keet.
1 Computer Graphics Week9 -3D Geometric Transformation.
Transformation.
3D Transformations. Translation x’ = x + tx y’ = y + ty z’ = z + tz P = P’ = T = P’ = T. P tx ty tz xyz1xyz1 x’ y’ z’ 1 x y.
Geometric Transformations
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Honours Graphics 2008 Session 2. Today’s focus Vectors, matrices and associated math Transformations and concatenation 3D space.
3D Coordinate Systems o3D computer graphics involves the additional dimension of depth, allowing more realistic representations of 3D objects in the real.
Composing Transformations
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
2D Transformation Homogenous Coordinates Scale/Rotate/Reflect/Shear: X’ = XT Translate: X’ = X + T Multiple values for the same point e.g., (2, 3, 6)
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSCE 441 Computer Graphics: 2D Transformations
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Modeling Transformation
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Transforms.
2D Transformations By: KanwarjeetSingh
Summary of Properties of 3D Affine Transformations
Review: Transformations
3D Geometric Transformations
Review: Transformations
2D Transformations y y x x y x.
Homogeneous Coordinates (Projective Space)
Three-Dimensional Graphics
Transformations.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Geometric Camera Models
Chapter IV Spaces and Transforms
2D Geometric Transformations
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Three-Dimensional Graphics
Geometric Objects and Transformations (II)
TWO DIMENSIONAL TRANSFORMATION
Presentation transcript:

2D Transformation

Transformation changes an object’s: – Position(Translation) – Size(Scaling) – Orientation(Rotation) – Shape(Deformation) Transformation is done by a sequence of matrix operations applied on vertices. 2D Transformation

Vector Representation If we define a 2D vector as: A transformation in general can be defined as:

Transformation: Translation Given a position ( x, y ) and an offset vector ( tx, ty ):

Transformation: Translation To translate the whole shape:

Transformation: Rotation Default rotation center: origin

Transformation: Rotation If We rotate around the origin, How to rotate a vector ( x, y ) by an angle of θ ? If we assume:

Transformation: Rotation Before RotationAfter Rotation

Transformation: Rotation To translate the whole shape:

Transformation: Scaling Change the object size by a factor of s : (2, 1) (-2, -1) s = 2 (4, 2) (-4, -2)

Transformation: Scaling But when the object is not center at origin (5, 3) (1, 1) s = 2 (10, 6) (2, 2) (3, 2) (6, 4)

Transformation: Scaling or Isotropic (uniform) scaling Anistropic (non-uniform) scaling

Summary Translation: Rotation Scaling

Summary Translation: Rotation Scaling We use the homogenous coordinate to make sure transformations have the same form.

Why use 3-by-3 matrices? Transformations now become the consistent. Represented by as matrix-vector multiplication. We can stack transformations using matrix multiplications.

Some math… Two vectors are orthogonal if:

A Quiz

Some math… A matrix is orthogonal if and only if:

Some math… A matrix M is orthogonal if and only if: Diagonal Matrix

Some math… A vector is normalized if:

Some math… A matrix is orthonormal if and only if: Ortho: Normalized:

Some math… A matrix M is orthonormal if and only if: Identity Matrix

Examples A 2D rotational matrix is orthonormal: Ortho: Normalized:

Examples Is a 2D scaling matrix orthonormal? (if sx, sy is not 1) Ortho: Normalized:

Summary TransformationExists?Ortho?Normalized? TranslationNoNA RotationYes ScalingYes No 2D Transformation (2-by-2 matrix) TransformationExists?Ortho?Normalized? TranslationYesNo RotationYes ScalingYes No 2D Transformation (3-by-3 matrix)

Transformation: Shearing y is unchanged. x is shifted according to y. or

Transformation: Shearing or

Facts about shearing Any 2D rotation matrix can be defined as the multiplication of three shearing matrices. Shearing doesn’t change the object area. Shearing can be defined as: rotation->scaling->rotation

In fact, Without translation, any 2D transformation matrix can be defined as: Rotation->Scaling->rotation Orthonormal Diagonal Orthonormal Singular Value Decomposition (SVD)

Another fact Same thing when using homogenous coordinates: Orthonormal Diagonal Orthonormal

Conclusion Translation, rotation, and scaling are three basic transformations. The combination of these can represent any transformation in 2D. That’s why OpenGL only defines these three.

Rotation Revisit Rotate about the originRotate about any center?

Arbitrary Rotation = Step 1: Translate ( -ox, -oy ) Step2: Rotate ( θ ) Step 1: Translate ( ox, oy ) (ox, oy)

Scaling Revisit (5, 3) (1, 1) (10, 6) (2, 2) (3, 2) (6, 4) (10, 6) (3, 2)

Arbitrary Scaling = Step 1: Translate ( -ox, -oy ) Step2: Scale( sx, sy ) Step 1: Translate ( ox, oy ) (ox, oy) ( ox, oy ) can be arbitrary too!

Rigid Transformation A rigid transformation is: Rotation and translation are rigid transformation. Any combination of them is also rigid. Orthonormal Matrix

Affine Transformation An affine transformation is: Rotation, scaling, translation are affine transformation. Any combination of them (e.g., shearing) is also affine. Any affine transformation can be decomposed into: Translation->Rotation->Scaling->Rotation (First)(Last)

We can also compose matrix Translation Scaling Rotation Translation M1M1 M2M2 M3M3 M4M4 v v’ v’ = (M 1 (M 2 ( M 3 (M 4 v)))) v’ = M v

Some Math Matrix multiplications are associative: Matrix multiplications are not commutative: Some exceptions are: Translation X Translation Scaling X Scaling Rotation X Rotation Uniform scaling X Rotation

For example Rotation and translation are not commutative: Orders are important!

How OpenGL handles transformation All OpenGL transformations are in 3D. We can ignore z-axis to do 2D transformation.

For example 3D Translation 2D Translation glTranslatef(tx, ty, tz) glTranslatef(tx, ty, 0)

For example 3D Rotation 2D Rotation glTranslatef(angle, axis_x, axis_y, axis_z) Z-axis (0, 0, 1) to toward you glTranslatef(angle, 0, 0, 1)

OpenGL uses two matrices: Projection Matrix ModelView Matrix Each object’s local coordinate Each object’s World coordinate Screen coordinate For example: gluOrtho2D(…)

How OpenGL handles transformation So you need to let OpenGL know which matrix to transform: You can reset the matrix as: glMatrixMode(GL_MODELVIEW); glLoadIdentity();

For Example Xcode time!