1 / 15

Chapter 3: Geometric Objects and Transformations

Chapter 3: Geometric Objects and Transformations. Vectors and Matrices Dot Products Cross Products Affine Transformations Rotation, Scaling, and Translation Homogeneous Coordinates. Vectors and Matrices 2D Parametric Equations.

jory
Télécharger la présentation

Chapter 3: Geometric Objects and 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. Chapter 3: Geometric Objects and Transformations • Vectors and Matrices • Dot Products • Cross Products • Affine Transformations • Rotation, Scaling, and Translation • Homogeneous Coordinates Chapter 3: Geometric Objects and Transformations

  2. Vectors and Matrices 2D Parametric Equations Given points P0 = (x0 , y0 ) and P1 = (x1 , y1 ), the segment between these points can be determined by the equation: Viewed in terms of the individual coordinates, this amounts to: P1 t = 0.9 P(0.9) = 0.1P0 + 0.9P1 t = 0.25 P(0.25) = 0.75P0 + 0.25P1 t = 1 P(1) = P1 t = 0 P(0) = P0 t = 0.5 P(0.5) = 0.5P0 + 0.5P1 P0 Chapter 4: Geometric Objects and Transformations

  3. Vectors and Matrices Vectors v -v u+v u u-v A vector is an array of values representing not a position, but a direction and a magnitude. For example, all of the vectors illustrated below are the same vector, but their positions vary: Vectors may be added together, subtracted from each other, and scaled by a constant factor: Chapter 4: Geometric Objects and Transformations

  4. Vectors and Matrices Dot Product v  u Dot product positive: Acute angle Dot product zero: Right angle Dot product negative: Obtuse angle When placed at the same starting position, the angle between two vectors u and v can be determined by their dot product: The Pythagorean Theorem allows us to conclude the following: where  is the angle between the two vectors. Chapter 4: Geometric Objects and Transformations

  5. Vectors and Matrices Dot Product Application: Determining Intersections P1 P1 Q0 Q0 Q0 P0 Q1 Q1 P1 Q1 P0 P0 If t < 0, then there is no intersection. If 0 ≤ t ≤ 1, then P(t) is the intersection. If t > 1, then there is no intersection. Parametric equations and dot products are useful when trying to determine the intersection between two line segments. If N is a normal vector to segment Q (i.e., perpendicular to the vector between Q0 and Q1), then solve the following equation for t: Chapter 4: Geometric Objects and Transformations

  6. Vectors and Matrices Cross Product u  v v  u When placed at the same starting position, a normal vector between two vectors u and v (i.e., a vector perpendicular to bothu and v) can be determined by their cross product: where k is the unit vector in the positive z direction. Again, the Pythagorean Theorem allows us to conclude that: where  is the angle between the two vectors. (Recall that the “right-hand rule” applies, so v  u = -u  v.) Chapter 4: Geometric Objects and Transformations

  7. Vectors and Matrices Cross Product: Polygon Convexity A polygon is convex the segment between any two points on its boundary is completely contained within the polygon. Some graphical algorithms depend on polygons being convex. To determine whether a polygon is convex, take the cross product of each pair of vectors between consecutive vertex triples. If all of these cross products have the same sign, then the polygon is convex. Positive cross product Positive cross product Positive cross product Positive cross product Positive cross product Negative cross product Positive cross product Positive cross product Positive cross product Positive cross product Chapter 4: Geometric Objects and Transformations

  8. Affine Transformations Transformation Types To effectively place objects in a graphical environment, it is convenient to use certain matrix transformations to manipulate their position and orientation. The specific types of transformations that we use are: • Scaling: multiply each dimension by a constant factor • Translation: add a constant amount in each dimension • Rotation: spin each object some angle around the origin Carefully combining these three types of transformations will permit a graphical object to be positioned and oriented in any desired fashion. Chapter 4: Geometric Objects and Transformations

  9. Affine Transformations Rotation 2D Rotation: (xcos - ysin, xsin + ycos)  (x, y) Chapter 4: Geometric Objects and Transformations

  10. Affine Transformations Scaling 2D Scaling: (x, y) (k1x, k2y) Chapter 4: Geometric Objects and Transformations

  11. Affine Transformations Translation y (x, y) x 2D Translation: (x + x, y + y) Any 2x2 matrix representing translation would require non-constant values in the matrix (requiring a separate matrix for each point being translated!) Chapter 4: Geometric Objects and Transformations

  12. Affine Transformations Homogeneous Coordinates The translation matrix problem is remedied by the use of homogeneous coordinates, which utilize an extra coordinate (i.e., a “weight” factor) for every 2D point. Rotation Scaling Translation (Note: In most of our work, the weight factor will merely be 1.) Chapter 4: Geometric Objects and Transformations

  13. Affine Transformations Combining Transformations By applying different transformations in a particular order, graphical objects can be manipulated to form complex variations of their original forms. • Enlarge one copy of the original image via scaling, and then translate it to the right. • Shrink another copy of the original image via scaling, rotate it slightly counterclockwise, and then translate it higher and to the right. Original Image • Shrink a third copy of the original image via scaling, rotate it clockwise a bit less than the second image, and then translate it slightly higher and further to the right. Chapter 4: Geometric Objects and Transformations

  14. Affine Transformations Order of Transformations Care must be taken when applying transformations, since the resulting image varies with the order in which the transformations are applied. R=60 Counterclockwise Rotation S=150% x-Scaling & 50% Y-Scaling T=Translation by (-3,-1) R first S second T third S first T second R third Chapter 4: Geometric Objects and Transformations

  15. Quaternions Smooth Rotation Interpolations Traditionally, a graphical object’s orientation has been defined via rotations about the three coordinate axes (i.e., roll, yaw, and pitch). However, this approach can result in “gimbal lock”, in which rotation about one axis effectively overrides rotation about another axis. OpenGL uses rotation about a user-specified axis, but that approach can result in interpolations between orientations that do not appear smooth. A much smoother approach involves quaternions, four-dimensional versions of complex numbers that can essentially be viewed as a “look-at” vector, combined with a “roll” angle. quaternions may be used to create slerps, spherical linear interpolations, which compel the interpolated orientations to be along the great circle of a sphere. Chapter 4: Geometric Objects and Transformations

More Related