Affine Transformations

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Affine Transformations Jim Van Verth NVIDIA Corporation
Today Composing transformations 3D Transformations
Linear Transformations and Matrices Jim Van Verth Lars M. Bishop
Vectors, Points, Lines and Planes Jim Van Verth Lars M. Bishop
Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.
Homogeneous Transformations CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005.
Transformations Ed Angel Professor Emeritus of Computer Science
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
CS 691 Computational Photography Instructor: Gianfranco Doretto Image Warping.
Announcements. Structure-from-Motion Determining the 3-D structure of the world, and/or the motion of a camera using a sequence of images taken by a moving.
Computer Graphics Lecture 4 Geometry & Transformations.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Transformations II Week 2, Wed Jan 17
2-D Geometry. The Image Formation Pipeline Outline Vector, matrix basics 2-D point transformations Translation, scaling, rotation, shear Homogeneous.
3D Kinematics Eric Whitman 1/24/2010. Rigid Body State: 2D p.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
CS5500 Computer Graphics March 22, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
3D orientation.
CSCE 689: Computer Animation Rotation Representation and Interpolation
Transformations. 2 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple geometry, most of us.
Computer Graphics with OpenGL 3e
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
Rotations and Translations
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Lecture Notes: Computer Graphics.
3D Computer Graphics An oh so brief introduction.
Rotations and Translations
Transformations Jehee Lee Seoul National University.
Matrices, Transformations and the 3D Pipeline Matthew Rusch Paul Keet.
Geometric Objects and Transformation
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Affine Transformations.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Affine Geometry.
Computer Graphics Matrices
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Instructor: Mircea Nicolescu Lecture 9
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Computer Graphics I, Fall 2010 Transformations.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Image Warping 2D Geometric Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Transforms.
3. Transformation
Computer Graphics Transformations.
2D Transformations with Matrices
Review: Transformations
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS
Introduction to Computer Graphics CS 445 / 645
Review: Transformations
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Chapter IV Spaces and Transforms
3D Transformation CS380: Computer Graphics Sung-Eui Yoon (윤성의)
Geometrical Transformations
Linear Algebra A gentle introduction
Transformations 2 University of British Columbia
Presentation transcript:

Affine Transformations Jim Van Verth (jim@essentialmath.com) Lars M. Bishop (lars@essentialmath.com)

Affine Transformations Extension of linear transforms Lines preserved Distances and angles can change Transform in an affine space Almost all apply to both vectors and points – exception is translation Essential Math for Games

Affine Transformations The most common ones are translation, scale and rotation Translation moves an object along a direction vector Scale shrinks/grows the object size Rotation rotates the object around an axis vector Essential Math for Games

Affine Transformations Can’t use 3x3 matrix for R3 R3 affine xforms Perform linear transforms, not affine transforms Need another representation Essential Math for Games

Essential Math for Games What’s Wrong With A 3x3? Can’t construct a 3x3 matrix that will translate the point (0,0,0) The zeroes in the coordinate vector cancel out all the coefficients! Essential Math for Games

Homogeneous Coordinates One way is to use homogeneous coordinates Initially developed in the 40s for use in geometry Later found their way into computer graphics Allow us to perform affine transforms via matrices Essential Math for Games

Homogeneous Coordinates Convert point in Rn to one of equivalent points in homogeneous space RPn Point in RPn has n+1 coordinates So point in R3 (x y z) has corresponding points in RP3 (x’ y’ z’ w) Essential Math for Games

Homogeneous Coordinates How to convert an R3 coordinate to its homogeneous representation Pick a number for the fourth element, w, and scale the real coordinate by it (x y z) => (xw yw zw w) Standard value for w is 1, so: (x y z) => (x y z 1) Essential Math for Games

Homogeneous Coordinates Map back to R3 by dividing out the w (x' y' z' w) => (x'/w y'/w z'/w) Usually assume w = 1, so just drop the w (x' y' z' 1) => (x' y' z') But not always, so be careful! Essential Math for Games

Essential Math for Games Homogeneous Matrices N-dimensional affine transformation is n+1 dimensional linear transformation A 3D homogeneous transformation matrix is a 4x4 matrix Treat 3D homogeneous point as a 4D vector Essential Math for Games

Translation Revisited Remember translating the point (0,0,0)? No problem; right column is translation vector Essential Math for Games

Translation Txyz(a,b,c) Essential Math for Games

Essential Math for Games Transforming Point Can represent affine transform as block matrix multiplication Transform point P = (x, 1), get So y is translation part, what does A represent? Essential Math for Games

Essential Math for Games Transforming Vectors Represent vector with w = 0 (x, y, z) => (x, y, z, 0) Can also write as v => (v, 0) Think of as point at infinity Essential Math for Games

Essential Math for Games Transforming Vectors Apply affine transform to vector, get Applies linear transform A to vector So linear transforms are subset of affine transforms Note no translation: makes sense, vectors have no position! Essential Math for Games

Other Affine Transformations Remaining affine transformations are also linear transformations Can be applied to vectors as well Notice that the top-left 3x3 block in the translation example was the identity? Just place the linear transform in the upper-left 3x3 block, as follows… Essential Math for Games

Essential Math for Games Scaling Sxyz(a,b,c) Essential Math for Games

Rotating About the x-axis Rx() Essential Math for Games

Rotating About the y-axis Ry() Essential Math for Games

Rotation About the z-axis Rz() Essential Math for Games

Essential Math for Games Rotation Matrices Have some useful properties Are orthogonal, i.e., R-1 = RT Column vectors are transformed axis of old coordinate system We’ll see how we can use this later Essential Math for Games

Concatenation of Transformations Transforms concatenated into a single matrix by multiplying them together, in the order they are to occur Can then use single matrix to perform transforms on many points Essential Math for Games

Essential Math for Games Concatenation Can perform a series of transformations v’ = M1  v v’’ = M2  v’ w = M3  v’’ Substitute to get w = M3  M2  v’ w = M3  M2  M1  v Essential Math for Games

Essential Math for Games Concatenation Can combine series into one matrix that performs all of them M = M3  M2  M1 w = M  v Example: Euler rotations Essential Math for Games

Essential Math for Games Euler Angles Common representation for 3D orientation (common  best) Three Euler angles: Yaw = shaking your head, “no” Pitch = nodding your head, “yes” Roll = cocking your head sideways Essential Math for Games

Essential Math for Games The Euler Transform Each angle corresponds to a rotation about an axis (dependent on coordinate system) z x y Essential Math for Games

Essential Math for Games The Euler Transform Looking down the x-axis: Yaw = Rz Pitch = Ry Roll = Rx z x y Essential Math for Games

Essential Math for Games The Euler Transform For this coordinate system, the Euler Transform E E(y,p,r) = Rx(r) Ry(p) Rz(y) Again, E is orthogonal (it’s a pure rotation matrix) Essential Math for Games

Concatentation of Transforms Can concatenate any sequence of scale, rotation, translate Matrix products are non-commutative, so the order matters Translating the point (0, 0, 0) and then rotating will not yield the same point as rotating (0, 0, 0) then translating (rotation of (0, 0, 0) does nothing) Essential Math for Games

Concatentation of Transforms Similarly, scaling and rotation are non-commutative Example: rotate (1 0 0) by 90° around z, scale by (sx, sy, sz), get (0 sy 0) scale (1 0 0) by (sx, sy, sz), rotate (1 0 0) by 90° around z, get (0 sx 0) Essential Math for Games

Essential Math for Games Transformation Order To perform scale, then rotation, then translation (generally the order desired), use Essential Math for Games

Essential Math for Games Matrix Breakdown Rotation, scale in upper left 3x3 Translation rightmost column Does rotation/scale first, then translate Essential Math for Games

Essential Math for Games Better Format Problem: want to Translate object in space and change rotation and scale arbitrarily Handle rotation/scale separately Can’t do easily with 4x4 matrix format Involves SVD, Polar decomposition Messy, but we can do better using… Essential Math for Games

Essential Math for Games Rigid Body Transforms Any sequence of translation and rotation transformations Not scale or shear Object shape is not affected (preserves angles and lengths) Usually include uniform scale despite this Essential Math for Games

Essential Math for Games Better Format Scale – one uniform scale factor s Rotation – 3x3 matrix R Translation – single vector t Essential Math for Games

Essential Math for Games Better Format Want to concatenate transforms T1, T2 in this form, or Do this by Essential Math for Games

Essential Math for Games Better Format Advantages Clear what each part does Easier to change individual elements Concat: 39 mult 27 add vs. 48 mult 32 add Disadvantages Eventually have to convert to 4x4 matrix anyway for renderer/video card Essential Math for Games

Essential Math for Games Better Format Matrix conversion Essential Math for Games

Inverting Rigid Body Xforms We can easily invert our rigid body transforms symbolically: Essential Math for Games

Inverting Rigid Body Xforms (2) In fact, the result itself may be written as a rigid body transform: Essential Math for Games

Essential Math for Games References Rogers, F. David and J. Alan Adams, Mathematical Elements for Computer Graphics, 2nd Ed, McGraw-Hill, 1990. Watt, Alan, 3D Computer Graphics, Addison-Wesley, Wokingham, England, 1993. Essential Math for Games