Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS

Similar presentations


Presentation on theme: "COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS"— Presentation transcript:

1 COMPUTER GRAPHICS CHAPTERS 10-11 CS 482 – Fall 2017 TRANSFORMATIONS
AFFINE TRANSFORMATIONS QUATERNIONS

2 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. CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 92

3 AFFINE TRANSFORMATIONS
ROTATION 2D Rotation: (xcos - ysin, xsin + ycos) (x, y) CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 93

4 AFFINE TRANSFORMATIONS
3D ROTATION Pitch: ROTATION ABOUT X-AXIS YAW: ROTATION ABOUT Y-AXIS Roll: ROTATION ABOUT Z-AXIS CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 94

5 AFFINE TRANSFORMATIONS
SCALING 2D Scaling: (x, y) (k1x, k2y) CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 95

6 AFFINE TRANSFORMATIONS
TRANSLATION 2D Translation: (x + x, y + y) y (x, y) x Any 2x2 matrix representing translation would require non-constant values in the matrix (requiring a separate matrix for each point being translated!) CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 96

7 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.) CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 97

8 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. CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 98

9 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 CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 99

10 CHAPTERS 10-11: TRANSFORMATIONS
QUATERNIONS SMOOTH ROTATIONS Traditionally, a graphical object’s orientation has been defined via “Euler angle” rotations about the three coordinate axes (i.e., pitch, yaw, and roll). 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 3D vector, combined with a scalar. q=𝑤+𝑥i+𝑦j+𝑧k CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 100

11 QUATERNIONS ROTATING IN OBJECT SPACE
To clarify, after combining several Euler angle rotations, it becomes difficult to rotate objects relative to their own space (due to Gimbal lock). Note in the image at right that an attempt to perform yaw rotation yields a spin around the y-axis in world space, but not in object space (as demonstrated by the non-stationary green arrow). Using quaternions eliminates this problem by performing operations in object space. Technically, quaternions space is a four-dimensional vector space that may be viewed as an extension of the two-dimensional complex plane, with a variation of cross products used for its (non-commutative) multiplication. CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 101

12 QUATERNIONS P  C Q SPHERICAL LINEAR INTERPOLATION
quaternions may be used to create slerps, spherical linear interpolations, which compel the interpolated orientations to be along the great circle of a sphere. Given a sphere with center C and surface points P and Q, where the angle between the CP and CQ vectors is . P The SLERP equation for all of the points on the great circle of the sphere joining P and Q is: C Q 𝑃 𝑡 =𝑃 sin 1−𝑡)𝜙 sin 𝜙 +𝑄 sin 𝑡𝜙 sin 𝜙 CS 482 – Fall 2017 CHAPTERS 10-11: TRANSFORMATIONS PAGE 102


Download ppt "COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS"

Similar presentations


Ads by Google