1TransformationsMike [email protected] State Universitymjb – September 5, 2014Oregon State UniversityComputer GraphicsGeometry vs. Topology1234434Original Objectmjb – September 5, 2014Oregon State UniversityComputer GraphicsWhere things are (e.g., coordinates)Geometry:How things are connectedTopology:123123Geometry = changedTopology = same (1-2-3-4-1)Geometry = sameTopology = changed (1-2-4-3-1)3D Coordinate SystemsYYZmjb – September 5, 2014Oregon State UniversityComputer GraphicsRight-HandedXZXLeft-HandedTransformationsYSuppose you have a point P and you want to move it over by 2 units in X – how would you change P’s coordinates?P P’mjb – September 5, 2014Oregon State UniversityComputer GraphicsX(,)( 2., )xyx yPPP P PThis is known as a coordinate transformationGeneral Form of 3D Linear TransformationsxAx By Cz DyExFyGzHIt’s called a “Linear Transformation” because all of the coordinates are raised to the 1stpower, that is, there are no x2, x3, etc. terms.mjb – September 5, 2014Oregon State UniversityComputer GraphicsTransform the geometry – leave the topology as isz IxJyKzL Translation EquationsxxxTyyyTmjb – September 5, 2014Oregon State UniversityComputer GraphicszzzTxTyT2Scaling About the OriginxxxS yyyS mjb – September 5, 2014Oregon State UniversityComputer GraphicszzzS 2D Rotation About the Origincos sinxx ysin cosyx ymjb – September 5, 2014Oregon State UniversityComputer Graphicssin cosyx yLinear Equations in Matrix FormxAx By Cz DyExFyGzHzIxJyKzL x consuming columny consuming columnz consuming columnconstant columnmjb – September 5, 2014Oregon State UniversityComputer Graphics100011xABCD xyEFGHyzIJKLz x’ producing rowy’ producing rowz’ producing rowIdentity Matrix ( [ I ] )1000xx xxmjb – September 5, 2014Oregon State UniversityComputer Graphics[ I ] signifies that “Nothing has changed”010000101 0001 1yyzz yyzzMatrix Inverse[M]•[M]-1= [I][M]•[M]-1= “Nothing has changed”mjb – September 5, 2014Oregon State UniversityComputer Graphics[][]gg“Whatever [M] does, [M]-1undoes”Translation Matrix100T mjb – September 5, 2014Oregon State UniversityComputer Graphics1000100011 000 1 1xyzxTxyTyzTz Quick! What is the inverse of this matrix?3Scaling Matrix000xS x mjb – September 5, 2014Oregon State UniversityComputer Graphics00000000 0100011xyzxS xyS yzSz Quick! What is the inverse of this matrix?3D Rotation Matrix About ZRight-handed positive rotation ruleRight-handed coordinates+90º rotation gives: y’ = xYmjb – September 5, 2014Oregon State UniversityComputer Graphicscos sin 0 0sin cos 0 00010100011xxyyzz gyXZ3D Rotation Matrix About YXYmjb – September 5, 2014Oregon State UniversityComputer GraphicsXZcos 0 sin 00100sin 0 cos 0100011xxyyzz +90º rotation gives: x’ = z3D Rotation Matrix About XY+90º rotation gives: z’ = ymjb – September 5, 2014Oregon State UniversityComputer GraphicsXZ10 0 00cos sin 00sin cos 0100 011xxyyzz How it Really Works :-)mjb – September 5, 2014Oregon State UniversityComputer Graphicshttp://xkcd.comCompound TransformationsAABBWrite itXYQ: Our rotation matrices only work around the origin? What if we want to rotate about an arbitrary point (A,B)?A: Use more than one matrix.mjb – September 5, 2014Oregon State UniversityComputer GraphicsWSay it,,11AB ABxxyyTRTzz 1234Matrix Multiplication is not CommutativeYRotate, then translateXYmjb – September 5, 2014Oregon State UniversityComputer GraphicsXTranslate, then rotateXYXMatrix Multiplication is Associative,,11AB ABxxyyTRTzz mjb – September 5, 2014Oregon State UniversityComputer Graphics,,11AB ABxxyyTRTzz One matrix –the Current Transformation Matrix, or CTM}Can Multiply All Geometry by One Matrix !AABBXY[]xxyyM mjb – September 5, 2014Oregon State UniversityComputer GraphicsGraphics hardware can do this very quickly!11[]yyzzM OpenGL Will Do the Transformation Compounding for You !glTranslatef( A, B, C );glRotatef( (GLfloat)Yrot, 0., 1., 0. );glRotatef( (GLfloat)Xrot, 1., 0., 0. );glScalef( (GLfloat)Scale, (GLfloat)Scale, (GLfloat)Scale );glCallList( BoxList );. );. );at)Scale, (GLfloat)Scale );Typically objects are modeled around their own local origin, so theglTranslate( -A, -B, -C )mjb – September 5, 2014Oregon State UniversityComputer GraphicsglTranslatef( A, B, C );glRotatef( (GLfloat)Yrot, 0., 1.,
View Full Document