DOC PREVIEW
Berkeley COMPSCI 184 - Lecture 4, 2D Transformations

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS-184: Computer GraphicsLecture #4: 2D Transformations Prof. James O’BrienUniversity of California, BerkeleyV2009-F-04-1.02Today•2D Transformations•“Primitive” Operations•Scale, Rotate, Shear, Flip, Translate•Homogenous Coordinates•SVD•Start thinking about rotations...3Introduction•Transformation: An operation that changes one configuration into another•For images, shapes, etc.A geometric transformation maps positions that define the object to other positionsLinear transformation means the transformation is defined by a linear function... which is what matrices are good for.4Some ExamplesImages from Conan The Destroyer, 1984OriginalUniform ScaleRotationNonuniform ScaleShear5Mapping Functionc(x)=[195, 120, 58]f (x)=x in old imagec!x = c( f (x))6Linear -vs- NonlinearLinear (shear)Nonlinear (swirl)7Geometric -vs- Color SpaceLinear Geometric(flip)Color Space Transform(edge finding)8InstancingRHWM.C. Escher, from Ghostscript 8.0 Distribution9InstancingRHW•Reuse geometric descriptions•Saves memory10Linear is Linear•Polygons defined by points•Edges defined by interpolation between two points•Interior defined by interpolation between all points•Linear interpolation11Linear is Linear•Composing two linear function is still linear•Transform polygon by transforming verticesScale12Linear is Linear•Composing two linear function is still linear•Transform polygon by transforming verticesf (x)=a + bxg( f )=c + dfg(x)=c + df(x )=c + ad + bdxg(x)=a!+ b!x13Points in Space•Represent point in space by vector in •Relative to some origin!•Relative to some coordinate axes!•Later we’ll add something extra...RnOrigin, 024T]4,2[=pp =[4, 2]T14Basic Transformations•Basic transforms are: rotate, scale, and translate•Shear is a composite transformation!RotateTranslateScaleShear -- not really “basic”Uniform/isotropicNon-uniform/anisotropic15Linear Functions in 2Dx!= f (x, y)=c1+ c2x + c3yy!= f (x, y)=d1+ d2x + d3y!x!y!"=!txty"+!MxxMxyMyxMyy"·!xy"x!= t + M · x16RotationsRotatepp−=)Cos()()()Cos('θθθθSinSinx.707 -.707.707 .707yx45 degree rotation17Rotations•Rotations are positive counter-clockwise•Consistent w/ right-hand rule•Don’t be different...•Note: •rotate by zero degrees give identity•rotations are modulo 360 (or )2π18Rotations•Preserve lengths and distance to origin•Rotation matrices are orthonormal• •In 2D rotations commute... •But in 3D they won’t!Det(R)=1 != −119Scales0.5 0 0 1.5xyxy            ScaleUniform/isotropicNon-uniform/anisotropicpp=yxss00'20Scales•Diagonal matrices•Diagonal parts are scale in X and scale in Y directions•Negative values flip•Two negatives make a positive (180 deg. rotation)•Really, axis-aligned scalesNot axis-aligned...21ShearsShearpp=11'xyyxHHx 1 1 0 1yxy22Shears•Shears are not really primitive transforms•Related to non-axis-aligned scales•More shortly.....23Translation•This is the not-so-useful way:Translate+=yxttpp'Note that its not like the others.24Arbitrary Matrices•For everything but translations we have:•Soon, translations will be assimilated as well•What does an arbitrary matrix mean?x!= A · x25Singular Value Decomposition•For any matrix, A , we can write SVD: where Q and R are orthonormal and S is diagonal•Can also write Polar Decomposition where Q is still orthonormalTQSRA =TQRSRA =not the same Q26Decomposing Matrices•We can force Q and R to have Det=1 so they are rotations•Any matrix is now:•Rotation:Rotation:Scale:Rotation•See, shear is just a mix of rotations and scales27Composition•Matrix multiplication composites matrices•Several translations composted to one•Translations still left out...BApp ='“Apply A to p and then apply B to that result.”CppBAApBp === )()('uCpBtBAptApBp +=+=+= )('27Composition•Matrix multiplication composites matrices•Several translations composted to one•Translations still left out...BApp ='“Apply A to p and then apply B to that result.”CppBAApBp === )()('uCpBtBAptApBp +=+=+= )('28CompositionshearxyxyyxxshearshearTransformations built up from othersSVD builds from scale and rotationsAlso build other waysi.e. 45 deg rotation built from shears29•Move to one higher dimensional space•Append a 1 at the end of the vectors•For directions the extra coordinate is a zeroHomogeneous Coordiantes=yxppp=1~yxppp30Homogeneous Translation=11001001'~yxyxppttppAp~~'~=The tildes are for clarity to distinguish homogenized from non-homogenized vectors.31Homogeneous Others=10000~AANow everything looks the same...Hence the term “homogenized!”32Compositing Matrices•Rotations and scales always about the origin•How to rotate/scale about another point?-vs-33Rotate About Arb. Point•Step 1: Translate point to originTranslate (-C)34Rotate About Arb. Point•Step 1: Translate point to origin•Step 2: Rotate as desiredTranslate (-C) Rotate (θ) 35•Step 1: Translate point to origin•Step 2: Rotate as desired•Step 3: Put back where it wasRotate About Arb. PointTranslate (-C) Rotate (θ) Translate (C)35•Step 1: Translate point to origin•Step 2: Rotate as desired•Step 3: Put back where it wasRotate About Arb. PointTranslate (-C) Rotate (θ) Translate (C) pApRTTp~~)('~=−=35Don’t negate the 1...•Step 1: Translate point to origin•Step 2: Rotate as desired•Step 3: Put back where it wasRotate About Arb. PointTranslate (-C) Rotate (θ) Translate (C) pApRTTp~~)('~=−=36Scale About Arb. Axis•Diagonal matrices scale about coordinate axes only:Not axis-aligned37Scale About Arb. Axis•Step 1: Translate axis to origin38Scale About Arb. Axis•Step 1: Translate axis to origin•Step 2: Rotate axis to align with one of the coordinate axes39Scale About Arb. Axis•Step 1: Translate axis to origin•Step 2: Rotate axis to align with one of the coordinate axes•Step 3: Scale as desired40Scale About Arb. Axis•Step 1: Translate axis to origin•Step 2: Rotate axis to align with one of the coordinate axes•Step 3: Scale as desired•Steps 4&5: Undo 2 and 1 (reverse order)41Order Matters!•The order that matrices appear in matters•Some special cases work, but they are special•But matrices are associative•Think about


View Full Document

Berkeley COMPSCI 184 - Lecture 4, 2D Transformations

Documents in this Course
Load more
Download Lecture 4, 2D Transformations
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 4, 2D Transformations and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 4, 2D Transformations 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?