1 / 35

Geometric Transformations

Geometric Transformations. Lecture 5 SE309-Computer graphics. Outline. The Coordinate Axes Homogeneous Coordinates Geometric Transformations Translations Rotations Scalings Reflections Assignment. The Coordinate Axes.

kedma
Download Presentation

Geometric Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Geometric Transformations Lecture 5 SE309-Computer graphics

  2. Outline • The Coordinate Axes • Homogeneous Coordinates • Geometric Transformations • Translations • Rotations • Scalings • Reflections • Assignment

  3. The Coordinate Axes • There are three mutually orthogonal axes: the x-axis, the y-axis, and the z-axis. • In the standard viewing position, the x- and y-axes look the same as in the usual 2D coordinate system. • The positive z-axis points towards the viewer; the negative z-axis points away.

  4. The Coordinate Axes

  5. The Coordinate Axes

  6. The Coordinate Axes

  7. Points and Homogeneous Coordinates • Points are represented in homogeneous coordinates(x; y; z;w), where w ≠ 0. • The standard 3-dimensional coordinates are given by (x=w; y=w; z=w). • For this reason, we usually want w = 1. • However, some transformations may change the w-coordinate.

  8. Geometric Transformations Definition (Isometry) • An isometry is a geometric transformation that preserves distances and angles. • Isometries • Translations • Rotations • Reflections • Non-isometries • Scalings • Shears

  9. 2D vs. 3D Transformations • All of these transformations may be performed in 2 or 3 dimensions. • When they are performed in 2 dimensions, typically the z-coordinate of the points is 0. • They are handled the same way whether in 2 or 3 dimensions.

  10. Translations • Definition (Translation) A translation is a displacement in a particular direction. • A translation is defined by specifying the displacements ∆x, ∆y, and ∆ z. x' = x + ∆ x y' = y + ∆ y z' = z + ∆ z

  11. Translations

  12. Translations

  13. Translations in OpenGL • The function glTranslate*(∆x, ∆y, ∆z) performs a translation through the displacement x, y, z. • To translate an object, this function should be called before the object is drawn.

  14. Translation Example • Example (Translation) glTranslatef(4.0, 2.0, -3.0); glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd();

  15. Rotations • Definition (Rotation) A rotation turns about a point (a; b) through an angle . • Generally we rotate about the origin. • Using the z-axis as the axis of rotation, the equations are xˈ = x cos  y sin y ˈ = x sin + y cos z ˈ = z

  16. Rotations

  17. Rotations

  18. Rotations in OpenGL • The function glRotate*(, a, b, c) will rotate about the line x = at, y = bt, z = ct through an angle , measured in degrees. • Typically, we rotate about • The x-axis (1; 0; 0), • The y-axis (0; 1; 0), or • The z-axis (0; 0; 1).

  19. Rotation Example • Example (Rotation) glRotatef(90.0, 0.0, 0.0, 1.0); glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd();

  20. Direction of Rotation • The direction of rotation is determined by the “right-hand rule.” • If you point your thumb in the positive direction of the axis of rotation, then when you curl your fingers, they will curl in the positive direction of rotation. • This rule works even if you are left-handed, as long as you use your right hand.

  21. Scaling • Definition (Scaling) A scaling is an expansion or contraction in the x, y, and z directions by scale factors sx, sy, and sz, and centered at a point (a; b; c). • Generally we center the scaling at the origin. xˈ = sxx yˈ = syy zˈ = szz

  22. Scaling

  23. Scaling

  24. Scalings in OpenGL • The function glScale*(s_x, s_y, s_z) will scale the drawing by factors sx, sy, and sz in the x-,y-, and z-directions. • The center of the scaling is the origin. • Never use a scale factor of 0.

  25. Scaling Example • Example (Scaling) glScalef(4.0, 2.0, 1.0); glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd();

  26. Reflections • Definition (Reflection) A reflection is a reversal of an object with respect to a line in 2 dimensions or a plane in 3 dimensions. • Generally we reflect in a line or plane through the origin.

  27. Reflections

  28. Reflections in the x-Axis

  29. Reflections in the y-Axis

  30. Reflections in the Line y=-x

  31. Reflections in OpenGL • The function glScale*(sx, sy, sz) will perform a reflection if two of the factors are 1 and one is -1. • For example, to reflect in the y-axis, use glScalef(1.0, -1.0, 1.0);

  32. Reflection Example • Example (Reflection) glScalef(1.0, -1.0, 1.0); glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd();

  33. Reflections • If we reflect in two axes at once (or in sequence), that amounts to a rotation of 180º in the axis perpendicular to those two axes. • For example, glScalef(-1.0, -1.0, 1.0); is equivalent to glRotatef(180.0, 0.0, 0.0, 1.0);

  34. Reflections • To accomplish a reflection in an arbitrary line L: ax + by = 0 through the origin, • First, reflect in the x-axis (y = 0). • Then rotate through twice the angle between the line L and the x-axis.

  35. Homework • Read Chapter3 – transformations. • Read Chapter3 – affine transformations. • Read Chapter3 – translations, rotations, and scalings.

More Related