Transformations CoordinateFree Geometry When we learned simple geometry
- Slides: 56
Transformations
Coordinate-Free Geometry • When we learned simple geometry, most of us started with a Cartesian approach Points were at locations in space p=(x, y, z) We derived results by algebraic manipulations involving these coordinates • This approach was nonphysical Physically, points exist regardless of the location of an arbitrary coordinate system Most geometric results are independent of the coordinate system Euclidean geometry: two triangles are identical if two corresponding sides and the angle between them are identical Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 2
Vectors • Physical definition: a vector is a quantity with two attributes Direction Magnitude • Examples include Force Velocity Directed line segments v • Most important example for graphics • Can map to other types Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 3
Vector Operations • Every vector has an inverse Same magnitude but points in opposite direction • Every vector can be multiplied by a scalar • There is a zero vector Zero magnitude, undefined orientation • The sum of any two vectors is a vector Use head to tail axiom v -v v w v u Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 4
Linear Vector Spaces • Mathematical system for manipulating vectors • Operations Scalar vector multiplication u= v Vector vector addition: w=u+v • Expressions such as v=u+2 w-3 r Make sense in a vector space Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 5
Vectors Lack Position • These vectors are identical Same length and magnitude • Vectors spaces insufficient for geometry Need points Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 6
Points • Location in space • Operations allowed between points and vectors Point point subtraction yields a vector Equivalent to point+vector addition v=P QS P=v+Q Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 7
Affine Spaces • Point + a vector space • Operations Vector vector addition Scalar vector multiplication Point vector addition Scalar scalar operations • For any point define 1 • P=P 0 • P = 0 (zero vector) Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 8
Rays and Line Segments • If >= 0, then P( ) is the ray leaving P 0 in the direction d If we use two points to define v, then P( ) = Q + (R Q)=Q+ v = R + (1 )Q For 0<= <=1 we get all the points on the line segment joining R and Q E. Angel and D. Shreiner: Interactive Computer Graphics 6 E © Addison Wesley 2012. 9
Planes • A plane be determined by a point and two vectors or by three points P( , b)=R+ u+bv P( , b)=R+ (Q R)+b(P Q) Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 10
Triangles convex sum of S( ) and R convex sum of P and Q for 0<= , b<=1, we get all points in triangle E. Angel and D. Shreiner: Interactive Computer Graphics 6 E © Addison Wesley 2012. 11
Barycentric Coordinates Triangle is convex so any point inside can be represented as an affine sum P( 1, 2, 3)= 1 P+ 2 Q+ 3 R where 1 + 2 + 3 = 1 i>=0 The representation is called the barycentric coordinate representation of P E. Angel and D. Shreiner: Interactive Computer Graphics 6 E © Addison Wesley 2012. 12
Affine Sums • Consider the “sum” P= 1 P 1+ 2 P 2+…. . + n. Pn Can show by induction that this sum makes sense iff 1+ 2+…. . n=1 in which case we have the affine sum of the points P 1, P 2, …. . Pn • If, in addition, i>=0, we have the convex hull of P 1, P 2, …. . Pn E. Angel and D. Shreiner: Interactive Computer Graphics 6 E © Addison Wesley 2012. 13
Normals • Every plane has a vector n normal (perpendicular, orthogonal) to it • From point two vector form P( , b)=R+ u+bv, we know we can use the cross product to find n = u v and the equivalent form (P( ) P) n=0 v P u Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 14
Linear Independence • A set of vectors v 1, v 2, …, vn is linearly independent if 1 v 1+ 2 v 2+. . nvn=0 iff 1= 2=…=0 • If a set of vectors is linearly independent, we cannot represent one in terms of the others • If a set of vectors is linearly dependent, at least one can be written in terms of the others E. Angel and D. Shriener: Interactive Computer Graphics 6 E © Addison Wesley 2012 15
Dimension • In a vector space, the maximum number of linearly independent vectors is fixed and is called the dimension of the space • In an n dimensional space, any set of n linearly independent vectors form a basis for the space • Given a basis v 1, v 2, …. , vn, any vector v can be written as v= 1 v 1+ 2 v 2 +…. + nvn where the { i} are unique E. Angel and D. Shriener: Interactive Computer Graphics 6 E © Addison Wesley 2012 16
Representation • Until now we have been able to work with geometric entities without using any frame of reference, such as a coordinate system • Need a frame of reference to relate points and objects to our physical world. For example, where is a point? Can’t answer without a reference system World coordinates Camera coordinates Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 17
Coordinate Systems • Consider a basis v 1, v 2, …. , vn • A vector is written v= 1 v 1+ 2 v 2 +…. + nvn • The list of scalars { 1, 2, …. n}is the representation of v with respect to the given basis • We can write the representation as a row or column array of scalars a=[ 1 2 …. n]T= Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 18
Example • V=2 v 1+3 v 2 4 v 3 • A=[2 3 – 4] • Note that this representation is with respect to a particular basis • For example, in Open. GL we start by representing vectors using the world basis but later the system needs a representation in terms of the camera or eye basis Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 19
Coordinate Systems • Which is correct? v v • Both are because vectors have no fixed location Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 20
Frames • Coordinate System is insufficient to present points • If we work in an affine space we can add a single point, the origin, to the basis vectors to form a frame v 2 P 0 v 1 v 3 Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 21
• Frame determined by (P 0, v 1, v 2, v 3) • Within this frame, every vector can be written as v= 1 v 1+ 2 v 2 +…. + nvn • Every point can be written as P = P 0 + b 1 v 1+ b 2 v 2 +…. +bnvn Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 22
Confusing Points and Vectors Consider the point and the vector P = P 0 + b 1 v 1+ b 2 v 2 +…. +bnvn v= 1 v 1+ 2 v 2 +…. + nvn They appear to have the similar representations p=[b 1 b 2 b 3] v=[ 1 2 3] v which confuse the point with the vector p A vector has no position v can place anywhere fixed Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 23
A Single Representation If we define 0 • P = 0 and 1 • P =P then we can write v= 1 v 1+ 2 v 2 + 3 v 3 = [ 1 2 3 0 ] [v 1 v 2 v 3 P 0] T P = P 0 + b 1 v 1+ b 2 v 2 +b 3 v 3= [b 1 b 2 b 3 1 ] [v 1 v 2 v 3 P 0] T Thus we obtain the four dimensional homogeneous coordinate representation v = [ 1 2 3 0 ] T T p = [b 1 b 2 b 3 1 ] Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 24
Homogeneous Coordinates The general form of four dimensional homogeneous coordinates is p=[x y z w] T We return to a three dimensional point (for w 0) by x x/w y y/w z z/w If w=0, the representation is that of a vector Note that homogeneous coordinates replaces points in three dimensions by lines through the origin in four dimensions Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 25
Homogeneous Coordinates and Computer Graphics • Homogeneous coordinates are key to all computer graphics systems All standard transformations (rotation, translation, scaling) can be implemented by matrix multiplications with 4 x 4 matrices Hardware pipeline works with 4 dimensional representations For orthographic viewing, we can maintain w=0 for vectors and w=1 for points For perspective we need a perspective division Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 26
Change of Coordinate Systems • Consider two representations of a the same vector with respect to two different bases. The representations are a=[ 1 2 3 ] b=[b 1 b 2 b 3] where v= 1 v 1+ 2 v 2 + 3 v 3 = [ 1 2 3] [v 1 v 2 v 3] T =b u +b u = [b b b ] [u u u ] T 1 1 2 2 3 3 1 2 3 1 Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 2 3 27
Representing second basis in terms of first Each of the basis vectors, u 1, u 2, u 3, are vectors that can be represented in terms of the first basis v u 1 = g 11 v 1+g 12 v 2+g 13 v 3 u 2 = g 21 v 1+g 22 v 2+g 23 v 3 u 3 = g 31 v 1+g 32 v 2+g 33 v 3 Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 28
Matrix Form The coefficients define a 3 x 3 matrix M= and the basis can be related by a=MTb see text for numerical examples Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 29
Change of Frames • We can apply a similar process in homogeneous coordinates to the representations of both points anduvectors 1 v 2 • Consider two frames (P 0, v 1, v 2, v 3) (Q 0, u 1, u 2, u 3) P 0 v 3 u 2 Q 0 v 1 u 3 • Any point or vector can be represented in each Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 30
Representing One Frame in Terms of the Other Extending what we did with change of bases u 1 = g 11 v 1+g 12 v 2+g 13 v 3 u 2 = g 21 v 1+g 22 v 2+g 23 v 3 u 3 = g 31 v 1+g 32 v 2+g 33 v 3 Q 0 = g 41 v 1+g 42 v 2+g 43 v 3 +g 44 P 0 defining a 4 x 4 matrix M= Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 31
Working with Representations Within the two frames any point or vector has a representation of the same form a=[ 1 2 3 4 ] in the first frame b=[b 1 b 2 b 3 b 4 ] in the second frame where 4 = b 4 = 1 for points and 4 = b 4 = 0 for vectors and a=MTb The matrix M is 4 x 4 and specifies an affine transformation in homogeneous coordinates Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 32
Affine Transformations • Every linear transformation is equivalent to a change in frames • Every affine transformation preserves lines • However, an affine transformation has only 12 degrees of freedom because 4 of the elements in the matrix are fixed and are a subset of all possible 4 x 4 linear transformations Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 33
The World and Camera Frames • When we work with representations, we work with n tuples or arrays of scalars • Changes in frame are then defined by 4 x 4 matrices • In. Open. GL, the base frame that we start with is the world frame • Eventually we represent entities in the camera frame by changing the world representation using the model view matrix • Initially these frames are the same (M=I) Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 34
Moving the Camera If objects are on both sides of z=0, we must move camera frame M= Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 35
General Transformations • A transformation maps points to other points and/or vectors to other vectors v=T(u) Q=T(P) Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 36
Affine Transformations • Line preserving • Characteristic of many physically important transformations Rigid body transformations: rotation, translation Scaling, shear • Importance in graphics is that we need only transform endpoints of line segments and let implementation draw line segment between the transformed endpoints Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 37
2 D Transformation • Translation y P’(x’, y’) dy P(x, y) x dx 38
2 D Transformation • Scaling y P 1(x 1, y 1) y 1 y 0 P 0(x 0, y 0) 1 y 1 2 1 y 0 2 x 1 x 1 x 1 0 2 2 x 1 39 x 0
2 D Transformation • Rotation y P’(x’, y’) P(x, y) x 40
2 D Transformation • Derivation of the rotation equation y P’(x’, y’) rsin( + ) P(x, y) rsin r rcos( + ) rcos 41 x
Translation • Move (translate, displace) a point to a new location P’ d P • Displacement determined by a vector d Three degrees of freedom P’=P+d Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 42
Translation Using Representations Using the homogeneous coordinate representation in some frame p=[ x y z 1]T p’=[x’ y’ z’ 1]T d=[dx dy dz 0]T Hence p’ = p + d or note that this expression is in x’=x+dx four dimensions and expresses y’=y+dy that point = vector + point z’=z+dz Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 43
Translation Matrix We can also express translation using a 4 x 4 matrix T in homogeneous coordinates p’=Tp where T = T(dx, dy, dz) = This form is better for implementation because all affine transformations can be expressed this way and multiple transformations can be concatenated together Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 44
Rotation (2 D) • Consider rotation about the origin by q degrees radius stays the same, angle increases by x = r cos (f + q) y = r sin (f + q) x’=x cos q –y sin q y’ = x sin q + y cos q x = r cos f y = r sin f Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 45
Rotation about the z axis • Rotation about z axis in three dimensions leaves all points with the same z Equivalent to rotation in two dimensions in planes of constant z x’=x cos q –y sin q y’ = x sin q + y cos q z’ =z or in homogeneous coordinates p’=Rz(q)p Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 46
Rotation Matrix R = Rz(q) = Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 47
Rotation about x and y axes • Same argument as for rotation about z axis For rotation about x axis, x is unchanged For rotation about y axis, y is unchanged R = Rx(q) = Ry(q) = Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 48
Scaling Expand or contract along each axis (fixed point of origin) x’=sxx y’=syy z’=szz p’=Sp S = S(sx, sy, sz) = Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 49
Reflection corresponds to negative scale factors sx = 1 sy = 1 original sx = 1 sy = 1 Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 50
Inverses • Although we could compute inverse matrices by general formulas, we can use simple geometric observations Translation: T 1(dx, dy, dz) = T( dx, dy, dz) Rotation: R 1(q) = R( q) • Holds for any rotation matrix • Note that since cos( q) = cos(q) and sin( q)= sin(q) R 1(q) = R T(q) Scaling: S 1(sx, sy, sz) = S(1/sx, 1/sy, 1/sz) Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 51
Concatenation • We can form arbitrary affine transformation matrices by multiplying together rotation, translation, and scaling matrices • Because the same transformation is applied to many vertices, the cost of forming a matrix M=ABCD is not significant compared to the cost of computing Mp for many vertices p • The difficult part is how to form a desired transformation from the specifications in the application Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 52
Order of Transformations • Note that matrix on the right is the first applied • Mathematically, the following are equivalent p’ = ABCp = A(B(Cp)) • Note many references use column matrices to present points. In terms of column matrices p. T ’ = p. T CT B T AT Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 53
General Rotation About the Origin A rotation by q about an arbitrary axis can be decomposed into the concatenation of rotations about the x, y, and z axes R(q) = Rz(qz) Ry(qy) Rx(qx) y qx qy qz are called the Euler angles Note that rotations do not commute We can use rotations in another order but with different angles q v x z Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 54
Rotation About a Fixed Point other than the Origin Move fixed point to origin Rotate Move fixed point back M = T(pf) R(q) T( pf) Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 55
Instancing • In modeling, we often start with a simple object centered at the origin, oriented with the axis, and at a standard size • We apply an instance transformation to its vertices to Scale Orient Locate Angel: Interactive Computer Graphics 3 E © Addison Wesley 2002 56
- Multiple transformations geometry
- Geometry topic 1 review
- Congruent segments
- Molecular geometry of pf3
- Electron domain geometry vs molecular geometry
- The basis of the vsepr model of molecular bonding is _____.
- Simple past simple present will future
- Past simple future simple
- Simple past simple present simple future
- презент перфект упражнения
- Simple past simple present simple future
- Present continuous present simple exercises
- Present tense to past tense
- Presente simples de work
- Present simple past simple future simple
- Simple geometry proofs
- Characters in the necklace
- Learned helplessness examples
- Sublimation defence mechanism
- Martin seligman optimism test
- In once upon a time who wears many faces like dresses
- Learned helpnessness
- Lessons learned faa
- Truffula tree the lorax coloring pages
- Is estivation innate or learned
- Euglena etymology
- Inherited behaviors examples
- Examples of acquired traits in humans
- The previous lesson
- Active artificial immunity
- Hyatt regency walkway collapse lessons learned
- Characteristics of an ant personality
- Why did muslims honor calligraphers above all other artists
- A child has learned to avoid a furry black cat
- Is classical conditioning learned or innate
- Learned behavior
- Change management lessons learned
- Cause and effect keywords
- Kinesis biology
- Uinnate
- Learned vs innate behavior
- Learned helplessness theory psychology
- Learned instinct
- Safety is a learned behavior and attitude
- You must unlearn what you have learned
- Already learned
- Workday claremont colleges
- Rationale of work immersion
- What have we learnt from the story
- The scholar mother tongue
- Valrox
- Violence as a modifier of human act
- Learned maladaptive behavior
- Molly was ecstatic when she learned her family
- Observational learning
- In the previous lesson you have learned
- Ojalá que ellos (descubrir) nuevas formas de energía.