Download presentation
Presentation is loading. Please wait.
Published byMagdalen Crawford Modified over 8 years ago
1
Transformations
2
Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation matrices Learn to build arbitrary transformation matrices from simple transformations
3
Transformations Transformations make possible the project of 3D objects onto 2D screen The graphics transformation process is analogous to taking a photograph with a camera Every transformation can be thought of as changing the representation of a vertex from one coordinate system to another
4
Affine Transformations Affine transformation is a special class of transformation that is very important for graphical applications. Affine transformation will not alter the type of object. A transformed line (polygon) is still a line (polygon). Any composition of affine transformations is still affine. Translation, rotation, scaling, reflection, and shear are examples of two-dimensional affine transformations. Any general two-dimensional affine transformation can always be expressed as a composition of these five transformations.
5
Translation Move (translate, displace) a point to a new location Displacement determined by a vector d Three degrees of freedom P’=P+d P P’ d
6
Translation P’ = P + Twhere Matrix representation:
7
Rotation (2D) Consider rotation about the origin by degrees ◦ radius stays the same, angle increases by x’=x cos –y sin y’ = x sin + y cos x = r cos y = r sin x = r cos ( y = r sin (
8
Rotation About the Origin Matrix representation: P’ = R·P where
9
UniformNon-Uniform (x,y) (x’,y’) (x,y) (x’,y’) Scaling About the Origin The parameters s x, s y are called scale factors.
10
Scaling About the Origin Matrix representation: P’ = S·P or
11
Cartesian Homogeneous Examples: (5, 8) (15, 24, 3) (x, y) (x, y, 1) Homogeneous Coordinates If we use homogeneous coordinates, the geometric transformations given above can be represented using only a matrix pre-multiplication. A composite transformation can then be represented by a product of the corresponding matrices.
12
Translation P’=TP Rotation [O] P’=RP Scaling [O] P’=SP Basic Transformations Homogeneous Coordinates
13
In composite transformations, the order of transformations is very important. Order of Transformations Rotation followed by Translation: Translation followed by Rotation:
14
OpenGL postmultiplies the current matrix with the new transformation matrix Order of Transformations (OpenGL) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(tx, ty, 0); glRotatef(theta, 0, 0, 1.0); glVertex2f(x,y); Rotation followed by Translation !! Current Matrix [ I ] [ T ] [ T ] [ R ] [ T ] [ R ] P
15
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Reflection corresponds to negative scale factors original s x = -1 s y = 1 s x = -1 s y = -1s x = 1 s y = -1
16
Reflections Matrix representation : Reflection about x-axis: M x = Reflection about y-axis: M y = Reflection about origin: M O =
17
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rotation About a Fixed Point other than the Origin Move fixed point to origin Rotate Move fixed point back M = T(p f ) R( ) T(-p f )
18
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shear Helpful to add one more basic transformation Equivalent to pulling faces in opposite directions
19
Matrix representation: Shear Shear along x-axis: H x (h) = Shear along x-axis: H y (h) =
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.