Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.

Slides:



Advertisements
Similar presentations
Points, Vectors, Lines, Spheres and Matrices
Advertisements

Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.
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.
Geometric Transformations
2-D Geometry. The Image Formation Pipeline Outline Vector, matrix basics 2-D point transformations Translation, scaling, rotation, shear Homogeneous.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
© 2003 by Davi GeigerComputer Vision October 2003 L1.1 Structure-from-EgoMotion (based on notes from David Jacobs, CS-Maryland) Determining the 3-D structure.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Computer Graphics with OpenGL 3e
Vectors.
CS 450: Computer Graphics 2D TRANSFORMATIONS
An Introduction to Robot Kinematics
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Mathematical Fundamentals
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Vectors. Definitions Scalar – magnitude only Vector – magnitude and direction I am traveling at 65 mph – speed is a scalar. It has magnitude but no direction.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Chapter 4.1 Mathematical Concepts
MATH 250 Linear Equations and Matrices
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.
Mathematical Foundations Sections A-1 to A-5 Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi.
Homogeneous Coordinates (Projective Space) Let be a point in Euclidean space Change to homogeneous coordinates: Defined up to scale: Can go back to non-homogeneous.
Course 12 Calibration. 1.Introduction In theoretic discussions, we have assumed: Camera is located at the origin of coordinate system of scene.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
POSITION & ORIENTATION ANALYSIS. This lecture continues the discussion on a body that cannot be treated as a single particle but as a combination of a.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Geometric Objects and Transformation
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Transformation.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
1 Graphics CSCI 343, Fall 2015 Lecture 10 Coordinate Transformations.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Composite 3D Transformations. Example of Composite 3D Transformations Try to transform the line segments P 1 P 2 and P 1 P 3 from their start position.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Affine Geometry.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Basic Theory (for curve 01). 1.1 Points and Vectors  Real life methods for constructing curves and surfaces often start with points and vectors, which.
Digital Image Processing Additional Material : Imaging Geometry 11 September 2006 Digital Image Processing Additional Material : Imaging Geometry 11 September.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Computer Graphics 2D Transformations
Geometric Transformations
Geometric Transformations Hearn & Baker Chapter 5
Computer Graphics Transformations.
Computer Graphics Transformations.
COMP 175: Computer Graphics February 9, 2016
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Chapter IV Spaces and Transforms
CSCE441: Computer Graphics 2D/3D Transformations
Presentation transcript:

Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation

Graphics Lecture 2: Slide 2 We previously defined transformation matrices for the most useful operations: Translation: Scaling:

Graphics Lecture 2: Slide 3 Rotations about the x, y and z axes We now consider more complex transformations which are combinations of these.

Graphics Lecture 2: Slide 4 Flying Sequences In generating animated flying sequences we require the viewpoint to move around the scene. This implies a change of origin Let the required viewpoint be C = [Cx,Cy,Cz] and the required view direction be d = [dx,dy,dz]

Graphics Lecture 2: Slide 5 Recall that we have a canonical form for Perspective Projection:

Graphics Lecture 2: Slide 6 Transformation of viewpoint C d

Graphics Lecture 2: Slide 7 Flying Sequences The required transformation is in three parts: 1. Translation of the Origin 2. Rotate about Y 3. Rotate about X The two rotations are to line up the z axis with the view direction

Graphics Lecture 2: Slide 8 Translation of the Origin C Viewing direction y z x y z x d d

Graphics Lecture 2: Slide 9 Rotate about Y until dx = 0  dzdz x z dxdx

Graphics Lecture 2: Slide 10 Rotate about X until dy = 0  z y |d||d| v dydy

Graphics Lecture 2: Slide 11 Combining the matrices The matrix that transforms the scene is: TABC T = A B C and for every point in the graphics scene we calculate T P’ = P T

Graphics Lecture 2: Slide 12 Verticals Notice we have not introduced verticals in the above analysis. Usually, the y direction is treated as vertical, and by doing the Ry transformation first, things work out correctly However it is possible to invert the vertical

Graphics Lecture 2: Slide 13 Rotate about Y Rotate about X Viewing Direction [0,0,-1] Y Z Y Z Vertical Inverted Vertical Preserved Y Z Transformations and Verticals

Graphics Lecture 2: Slide 14 Rotation about a general line Special effects, such as rotating a scene about a general line can be achieved by transformations, The transformation is formed by: Making the line of rotation one of the Cartesian axes Doing the rotation Restoring the line to its original place

Graphics Lecture 2: Slide 15 Rotation about a general line The first part is achieved by the same matrix that we derived for the flying sequences TABC T = A B C and the rest is achieved by a rotation followed by the inversion of T TABC Rz C B A T = A B C Rz C -1 B -1 A -1

Graphics Lecture 2: Slide 16 Other Effects Similar effects can be created using this approach eg Making objects shrink 1. Move the object to the origin 2. Apply a scaling matrix 3. Move the object back to where it was

Graphics Lecture 2: Slide 17 Projection by Matrix multiply Usually projection and drawing of a scene comes after transformation. It is therefore convenient to combine the projection with the other parts of the transformation

Graphics Lecture 2: Slide 18 Orthographic Projection Matrix For orthographic projection we simply drop the z coordinate: Note that the matrix is singular. Projection cannot be inverted..

Graphics Lecture 2: Slide 19 Perspective Projection Matrix Perspective projection of homogenous coordinates can also be done by matrix multiplication:

Graphics Lecture 2: Slide 20 Normalisation Remember that homogenous coordinates need to be normalised, so we need to divide by the last ordinate as a final step: [x, y, z, z/f] is normalised to [xf/z, yf/z, f, 1] as required.

Graphics Lecture 2: Slide 21 Projection matrices are singular Notice that projection matrices are singular (they cannot be inverted)‏ This is because a projection cannot be inverted, ie Given a 2D image, we cannot in general reconstruct the 3D original.

Graphics Lecture 2: Slide 22 Affine transformations Affine transformations: translation scaling rotation orthographic projection preserve parallelism and linearity. Non-affine transformations: perspective projection

Graphics Lecture 2: Slide 23 Homogenous Coordinates as Vectors We now take a second look at homogeneous coordinates, and their relation to vectors. In the previous lecture we described the fourth ordinate as a scale factor. [X, Y, Z, h] is equivalent to [X/h, Y/h, Z/h] Homogenous Cartesian

Graphics Lecture 2: Slide 24 Homogenous co-ordinates and vectors Homogenous co-ordinates fall into two types: 1.Those with the final ordinate non-zero, which can be normalised into position vectors. 2.Those with zero in the final ordinate which are direction vectors, and have direction magnitude.

Graphics Lecture 2: Slide 25 Vector Addition If we add two direction vectors, we obtain a direction vector. ie: [x i,y i,z i,0] + [x j,y j,z j,0] = [x i +x j, y i +y j, z i +z j,0] This is the normal vector addition rule.

Graphics Lecture 2: Slide 26 Adding position and direction vectors If we add a direction vector to a position vector we obtain a position vector: [X i,Y i,Z i,1]+[x j,y j,z j,0] = [X i +x j,Y i +y j,Z i +z j,1] P d Line L = P +  d This is a nice result, because it ties in with the definition of a straight line in Cartesian space which uses a point and a direction:

Graphics Lecture 2: Slide 27 Adding two position vectors If we add two position vectors we obtain their mid- point: [Xi,Yi,Zi,1] + [Xj,Yj,Zj,1] =[Xi+Xj, Yi+Yj, Zi+Zj, 2] = [(Xi+Xj)/2, (Yi+Yj)/2, (Zi+Zj)/2, 1] Note that this is a reasonable result since adding two position vectors has no meaning in vector algebra.

Graphics Lecture 2: Slide 28 The structure of a transformation matrix The rows of a transformation matrix comprise three direction vectors and one position vector. Direction vector Position vector

Graphics Lecture 2: Slide 29 Characteristics of Transformation matrices In a direction vector the zero in the last ordinate ensures vectors will not be affected by the translation. In a position vector the 1 in the last ordinate means all vectors will have the same displacement. If we do not shear the object the three vectors q r and s will remain orthogonal, ie: q r = r s = q s = 0.

Graphics Lecture 2: Slide 30 What the individual rows mean? To see this we consider the effect of the transformation in simple cases. For example take the unit vectors along the Cartesian axes eg along the x axis, i = [1,0,0,0]

Graphics Lecture 2: Slide 31 Axis Transformation Similarly we find that direction j = [0,1,0,0] will be transformed to direction [r x,r y,r z,0] and k = [0,0,1,0] will be transformed to [s x,s y,s z,0]

Graphics Lecture 2: Slide 32 Transforming the Origin If we transform the origin we end up with the bottom row of the transformation matrix.

Graphics Lecture 2: Slide 33 Meaning of a transformation matrix The original x-axis The original y axis The original z-axis The original origin The rows are the original axis system in the new coordinate system.

Graphics Lecture 2: Slide 34 Effect of a transformation matrix u v w k j i -C Origin i j k s r q C

Graphics Lecture 2: Slide 35 What we want is the other way round We are given the values of [u,v,w] and C and would like to know the transformation matrix that moves the scene to that coordinate system. To see how to do this we introduce the notion of the dot product as a projection. C u v w

Graphics Lecture 2: Slide 36 The dot product as projection P v u P.v P.u |P|  The dot product is defined as P.u = |P| |u| Cos  If u is a unit vector then P.u = |P| Cos  If u is one of the co-ordinate axes then P.u is the ordinate of P in the u direction.

Graphics Lecture 2: Slide 37 Changing axes by projection P-C C P y x z u w v Extending the idea to three dimensions we can see that a change of axes can be expressed as projections using the dot product. For example: P t x = (P-C).u = P.u - C

Graphics Lecture 2: Slide 38 Transforming point P Given point P in the [x,y,z] axis system, we can calculate the corresponding point in the [u,v,w] space as: P t x = (P-C).u = P.u - C.u P t y = (P-C).v = P.v - C.v P t z = (P-C).w = P.w - C.w or in matrix form:

Graphics Lecture 2: Slide 39 Verticals Unlike the previous analysis we now can control the vertical, ie the v direction is taken as the vertical and constrained by the software to be upwards

Graphics Lecture 2: Slide 40 Back to flying sequences We now return to the flying sequences problem and solve for the transformation matrix by finding the vectors u,v and w. Given a viewpoint point C and a view direction d we need to find the transformation matrix. We know that d is the direction of the new z axis, so we can write immediately: w = d/|d|

Graphics Lecture 2: Slide 41 Now the horizontal direction Let the horizontal direction be p Thus u = p/|p| To ensure that p is horizontal we need p y = 0 (p has no vertical component)‏

Graphics Lecture 2: Slide 42 And the vertical direction Let q be the vertical direction, thus v = q/|q| q must have a positive y component, so we can say: q y = 1

Graphics Lecture 2: Slide 43 So we have four unknowns p = [p x, 0, p z ] q = [q x, 1, q z ] To solve for these we use the cross product and dot product. Since the axis system is left handed: d = p x q (we can do this because p’s magnitude is not set)‏

Graphics Lecture 2: Slide 44 Evaluating the cross product so we have now completely determined vector p

Graphics Lecture 2: Slide 45 Using the dot product Lastly we can use the fact that the vectors p and q are orthogonal, thus p.q = 0 p x q x + p z q z = 0 and from the cross product (last slide)‏ d y = p z q x - p x q z So we have two simple linear equations to solve for q

Graphics Lecture 2: Slide 46 The final matrix As defined we have u = p/|p| v = q/|q| w= d/|d| so we can write down the matrix.