Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.

Similar presentations


Presentation on theme: "1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon."— Presentation transcript:

1 1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon

2 Transforming Pictures Sometimes objects exhibit certain symmetries, so only a part of it needs to be described, and the rest constructed by reflecting, rotating and translating the original part A designer may want to view and object from different vantage points, by rotating the object, or by moving a “synthetic camera” viewpoint. In animation, one or more objects must move relative to one another, so that their local co-ordinate systems must be shifted and rotated as the animation proceeds.

3 The snowflake exhibits symmetries. We design a single motif and draw the whole shape using appropriate reflections, rotations, and translations of the motif. Example 1

4 etc... Example 2 Object parts defined in a local co-ordinate system: Larger objects are then “assembled” by duplicating and transforming each of the constituent parts:

5 5 + + = This of course shouldn’t mean all objects need to share the same transformations Usually we model individual objects based on a local coordinate system Example 3

6 6 + = + transform + + Obviously we want something more versatile

7 5 steps of a “rotating cube” animation Example 4 At each frame of the animation, the object is transformed, in this case by a rotation. It could also be transformed by changing its size (scaling), or its shape (deformation), or its location (translation). Further animation effects can be achieved by not changing the object, but the way it is viewed zooming and panning the viewing window

8 Example 5 A designer may want to view an object from different vantage points. Positioning and reorienting a camera can be carried out through the use of 3D affine transformations.

9 Transformations A transformation on an object is an operation that changes how the object is finally drawn to screen There are two ways of understanding a transformation  An Object Transformation alters the coordinates of each point according to some rule, leaving the underlying coordinate system unchanged  A Coordinate Transformation produces a different coordinate system, and then represents all original points in this new system

10 {1,1} {.4, 2} Example: OBJECT TRANSFORMATION {1,1} Example: COORDINATE TRANSFORMATION More on this later…

11 11 Coordinate Transforms {1*,1*} v’ u’ {1,1} v u x y Object defined in Local Coordinate System Object after transformation in Global Coordinate System

12 12 x y x y Identity {1,1} v u v’ u’

13 13 x y Translation x y {1,1} v u {1+tx,1+ty} v’ u’ origin

14 14 x y Rotation x y {1,1} v u v’ u’

15 15 x y Scaling x y {1,1} v u {sx*1,sy*1} v u

16 16 3D Object Transformations translation rotation scaling

17 17 Scale all vectors are scaled from the origin: Originalscale all axesscale Y axis offset from origindistance from origin also scales

18 18 Scale Or in 3D homogeneous coordinates

19 19 Rotation Rotations are anti-clockwise about the origin: rotation of 45 o about the Z axis offset from origin rotation

20 20 Rotation 2D rotation of  about origin: 3D homogeneous rotations:

21 21 Translation Translation only applies to points, we never translate vectors. Remember: points have homogeneous co-ordinate w = 1 translate along y

22 Shear We shear along an axis according to another axis  Shearing along X axis preserves y and z values.  Shearing along Y axis preserves x and z values  Shearing along Z axis preserves x and y values Point are stretched along the shear axis in proportion to the distance of the point along another axis. Example: shearing along X according to Y

23 Shear originalshear along x (by y)shear along x (by z)

24 Transformation Composition More complex transformations can be created by concatenating or composing individual transformations together. Matrix multiplication is non-commutative  order is vital We can create an affine transformation representing rotation about a point P R : = translate to origin, rotate about origin, translate back to original location

25 Transformation Composition

26 Conceptually there is a 4 x 4 homogeneous coordinate matrix, the current transformation matrix (CTM) that is part of the state and is applied to all vertices that pass down the pipeline The CTM is defined in the user program and loaded into a transformation unit Current Transformation Matrix (CTM or CT) CTMvertices p p’=Cp C

27 In OpenGL matrices are part of the state Multiple types  Model-View (GL_MODELVIEW)  Projection (GL_PROJECTION)  Texture (GL_TEXTURE) (ignore for now)  Color(GL_COLOR) (ignore for now) Single set of functions for manipulation Select which to be manipulated by  glMatrixMode(GL_MODELVIEW);  glMatrixMode(GL_PROJECTION); OpenGL Matrices

28 Can load and multiply by matrices defined in the application program The matrix m is a one dimension array of 16 elements which are the components of the desired 4 x 4 matrix stored by columns In glMultMatrixf, m multiplies the existing matrix on the right Arbitrary Matrices glLoadMatrixf(m) glMultMatrixf(m)

29 glRotatef(theta, vx, vy, vz) Rotation, Translation, Scaling glTranslatef(dx, dy, dz) glScalef(sx, sy, sz) glLoadIdentity()  Load an identity matrix:  Multiply on right: theta in degrees, ( vx, vy, vz ) define axis of rotation  Each has a float (f) and double (d) format (glScaled)


Download ppt "1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon."

Similar presentations


Ads by Google