COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 17, 2015 TRANSFORMATIONS AFFINE TRANSFORMATIONS QUATERNIONS
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 TRANSFORMATION TYPES SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 80 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.
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 ROTATION SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 81 2D ROTATION: (x, y) (xcos - ysin , xsin + ycos )
AFFINE TRANSFORMATIONS CS 482 – FALL D ROTATION SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 82 PITCH: ROTATION ABOUT X- AXIS YAW: ROTATION ABOUT Y- AXIS ROLL: ROTATION ABOUT Z- AXIS
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 SCALING SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 83 2D SCALING: (x, y) (k 1 x, k 2 y)
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 TRANSLATION SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 84 2D TRANSLATION: (x, y) xx yy (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!)
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 HOMOGENEOUS COORDINATES SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 85 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 TRANSLATION SCALING (NOTE: IN MOST OF OUR WORK, THE WEIGHT FACTOR WILL MERELY BE 1.)
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 COMBINING TRANSFORMATIONS SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 86 Original Image BY APPLYING DIFFERENT TRANSFORMATIONS IN A PARTICULAR ORDER, GRAPHICAL OBJECTS CAN BE MANIPULATED TO FORM COMPLEX VARIATIONS OF THEIR ORIGINAL FORMS. 1.ENLARGE ONE COPY OF THE ORIGINAL IMAGE VIA SCALING, AND THEN TRANSLATE IT TO THE RIGHT. 2.SHRINK ANOTHER COPY OF THE ORIGINAL IMAGE VIA SCALING, ROTATE IT SLIGHTLY COUNTERCLOCKWISE, AND THEN TRANSLATE IT HIGHER AND TO THE RIGHT. 3.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.
AFFINE TRANSFORMATIONS CS 482 – FALL 2015 ORDER OF TRANSFORMATIONS SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 87 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) RfirstRfirstSsecondSsecondTthirdTthird SfirstSfirstTsecondTsecondRthirdRthird
QUATERNIONS CS 482 – FALL 2015 SMOOTH ROTATIONS SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 88 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.
QUATERNIONS CS 482 – FALL 2015 SPHERICAL LINEAR INTERPOLATION SEPTEMBER 17, 2015: TRANSFORMATIONSPAGE 89 QUATERNIONS MAY BE USED TO CREATE SLERPS, SPHERICAL LINEAR INTERPOLATIONS, WHICH COMPEL THE INTERPOLATED ORIENTATIONS TO BE ALONG THE GREAT CIRCLE OF A SPHERE. P Q C GIVEN A SPHERE WITH CENTER C AND SURFACE POINTS P AND Q, WHERE THE ANGLE BETWEEN THE CP AND CQ VECTORS IS . THE SLERP EQUATION FOR ALL OF THE POINTS ON THE GREAT CIRCLE OF THE SPHERE JOINING P AND Q IS: