Computer Graphics - Transformations - Philipp Slusallek
Vector Space β’ Math recap β 3D vector space over the real numbers π€ 1 β πΎ π = β π β’ π = π€ 2 π€ 3 β Vectors written as n x 1 matrices β Vectors describe directions β not positions ! β’ All vectors conceptually start from the origin of the coordinate system β 3 linear independent vectors create a basis β’ Standard basis e 3 1 0 0 π 1 , π 2 , π 3 = 0 , 1 , 0 e 2 0 0 1 e 1 β Any 3D vector can be represented uniquely with coordinates π€ π β’ π = π€ 1 π π + π€ 2 π π + π€ 3 π π π€ 1 , π€ 2 , π€ 3 β β
Vector Space - Metric β’ Standard scalar product a.k.a. dot or inner product β Measure lengths π€ 2 = π€ β π€ = π€ 1 2 + π€ 2 2 + π€ 3 2 β’ β Compute angles β’ π£ β π€ = π£ π€ cos(π£, π€) β Projection of vectors onto other vectors π£ cos(π) = π£β π€ π€ = π£β π€ β’ π€β π€ u Ι΅ v π£ cos(π)
Vector Space - Basis β’ Orthonormal basis β Unit length vectors β’ π 1 = π 1 = π 1 =1 β Orthogonal to each other β’ π π β π π = π ππ β’ Handedness of the coordinate system β Two options: π 1 Γ π 2 = Β±π 3 β’ Positive: Right-handed (RHS) β’ Negative: Left-handed (LHS) β Example: Screen Space β’ Typical: X goes right, Y goes up (thumb & index finger, respectively) β’ In a RHS: Z goes out of the screen (middle finger) β Be careful: β’ Most systems nowadays use a right handed coordinate system β’ But some are not (e.g. RenderMan) ο can cause lots of confusion
Affine Space β’ Basic mathematical concepts β Denoted as A 3 β’ Elements are positions (not directions!) b β Defined via its associated vector space V 3 v β’ π, π β π΅ 3 β β! π€ β π 3 : π€ = π β π a β’ β: unique, β: ambiguous β Operations on A 3 β’ Subtraction yields a vector β’ No addition of affine elements β Its not clear what the some of two points would mean β’ But: Addition of points and vectors: β π + π€ = π β π΅ 3 β’ Distance β πππ‘π’ π, π = π β π
Affine Space - Basis β’ Affine Basis β Given by its origin o (a point) and the basis of an associated vector space π π , π π , π π β π 3 ; π β π© π β’ π π , π π , π π , π : β’ Position vector of point p β (π β π) is in π 3 p e 3 p-o e 2 e 1 o
Affine Coordinates β’ Affine Combination β Linear combination of (n+1) points β’ π 0 , β¦ , π π β π΅ π β With weights forming a partition of unity β’ π½ 0 , β¦ , π½ π β β with π π½ π = 1 π π π β π = π=0 π½ π π π = π 0 + π=1 π½ π (π π β π 0 ) = π + π=1 π½ π π€ π β’ Basis β (π + 1) points form am affine basis of π΅ π β’ Iff none of these point can be expressed as an affine combination of the other points β’ Any point in π΅ π can then be uniquely represented as an affine combination of the affine basis π 0 , β¦ , π π β π΅ π β’ Any vector in another basis can be expressed as a linear combination of the π π , yielding a matrix for the basis
Affine Coordinates β’ Closely related to β Barycentric Coordinatesβ β Center of mass of (π + 1) points with arbitrary masses (weights) π π is given as p 1 π π π π π π = π π β’ π = π π π π = π½ π π π p β’ Convex / Affine Hull p 2 β If all π½ π are non-negative than p is in the convex hull of the other points β’ In 1D β Point is defined by the splitting ratio π½ 1 : π½ 2 πβπ 2 πβπ 1 β’ π = π½ 1 π 1 + π½ 2 π 2 = π 2 βπ 1 π 1 + π 2 βπ 1 π 2 π΅ 1 π΅ 2 β’ In 2D β Weights are the relative areas in Ξ(π΅ 1 , π΅ 2 , π΅ 3 ) Ξ(π,π΅ π+1 %3 ,π΅ π+2 %3 ) β’ π’ π = π½ π = Ξ(π΅ 1 ,π΅ 2 ,π΅ 3 ) Note: Length and area β’ π = π½ 1 π΅ 1 + π½ 2 π΅ 2 + π½ 3 π΅ 3 measures are signed here π΅ 3
Affine Mappings β’ Properties β Affine mapping (continuous, bijective, invertible) β’ T: A 3 β A 3 β Defined by two non-degenerated simplicies β’ 2D: Triangle, 3D: Tetrahedron, ... β Invariants under affine transformations: β’ Barycentric/affine coordinates β’ Straight lines, parallelism, splitting ratios, surface/volume ratios β Characterization via fixed points and lines β’ Given as eigenvalues and eigenvectors of the mapping β’ Representation β Matrix product and a translation vector: β’ πΌπ = π©π + π with A β β πΓπ , t β β π β Invariance of affine coordinates β’ πΌπ = πΌ π½ π π π = π© π½ π π π + π = π½ π (π©π π ) + π½ π π = π½ π (πΌπ π )
Homogeneous Coordinates for 3D Homogeneous embedding of R 3 into the projective 4D β’ space P(R 4 ) β Mapping into homogeneous space π¦ π¦ π§ β’ β 3 β β π β 4 π§ βΆ π¨ π¨ 1 β Mapping back by dividing through fourth component π π/π π β’ π/π βΆ π π/π π β’ Consequence β This allows to represent affine transformations as 4x4 matrices β Mathematical trick β’ Convenient representation to express rotations and translations as matrix multiplications β’ Easy to find line through points, point-line/line-line intersections β Also important for projections (later)
Point Representation in 2D β’ Point in homogeneous coordinates β All points along a line through the origin map to the same point in 2D π = (π, π, π) (x,y) W =1 π¦ = π π§ = π π π
Homogeneous Coordinates in 2D β’ Some tricks (work only in P(R 3 ), i.e. only in 2D) β Point representation π π¦ π π β π β 3 , β’ π = π§ = π π π π β Representation of a line π β β 2 β’ Dot product of l vector with point in plane must be zero: π π¦ π β π(β 3 ) π β π = 0, l= β π = π ππ¦ + ππ§ + π β 1 = 0 = π§ π β’ Line l is normal vector of the plane through origin and points on line β Line trough 2 points p and pβ β’ Line must be orthogonal to both points β’ π β π β§ π β² β π β π = π Γ π β² β Intersection of lines l and lβ: β’ Point on both lines ο¨ point must be orthogonal to both line vectors β’ π β π β© π β² β π = π Γ πβ²
Line Representation β’ Definition of a 2D Line in P(R 3 ) β Set of all point P where the dot product with l is zero π = (π, π, π) π = (π, π, π) π β π = 0
Line Representation β’ Line β Represented by normal vector to plane through line and origin π = (π, π, π) ππ¦ + ππ§ + π β 1 = 0
Line through 2 Points β’ Construct line through two points β Line vector must be orthogonal to both points β Compute through cross product of point coordinates π = (π, π, π) πβ² = (π, β² π, β² πβ²) π = (π, π, π) π = π Γ πβ²
Intersection of Lines β’ Construct intersection of two lines β A point that is on both lines and thus orthogonal to both lines β’ Computed by cross product of both line vectors π πβ² π π = π Γ πβ²
Orthonormal Matrices β’ Columns are orthogonal vectors of unit length β An example 0 0 1 β’ 1 0 0 0 1 0 β Directly derived from the definition of the matrix product: β’ π π π = 1 β In this case the transpose must be identical to the inverse: β’ π β1 β π π
Linear Transformation: Matrix β’ Transformations in a Vector space: Multiplication by a Matrix β Action of a linear transformation on a vector β’ Multiplication of matrix with column vectors (e.g. in 3D) π π π π β² π π¦π¦ π¦π§ π¦π¨ π β² = π π π π β² = πΌπ = π π§π¦ π§π§ π§π¨ π β² π π π π π¨π¦ π¨π§ π¨π¨ β’ Composition of transformations β Simple matrix multiplication ( πΌ π , then πΌ π ) β’ πΌ π πΌ π π = πΌ π πΌ π π = πΌ π πΌ π π = πΌπ β Note: matrix multiplication is associative but not commutative! β’ πΌ π πΌ π is not the same as πΌ π πΌ π (in general)
Affine Transformation β’ Remember: β Affine map: Linear mapping and a translation β’ πΌπ = π©π + π β’ For 3D: Combining it into one matrix β Using homogeneous 4D coordinates β Multiplication by 4x4 matrix in P(R 4 ) space π π π π π β² π¦π¦ π¦π§ π¦π¨ π¦π₯ π π π π π π β² π β’ π β² = π§π¦ π§π§ π§π¨ π§π₯ = ππ = π π π π π πβ² π¨π¦ π¨π§ π¨π¨ π¨π₯ πβ² π π π π π π₯π¦ π₯π§ π₯π¨ π₯π₯ β Allows for combining (concatenating) multiple transforms into one using normal (4x4) matrix products β’ Letβs go through the different transforms we need:
Transformations: Translation β’ Translation (T) 1 0 0 π’ π¦ π¦ π¦ + π’ π¦ 0 1 0 π’ π§ π§ π§ + π’ π§ β πΌ π’ π¦ , π’ π§ , π’ π¨ π = = π¨ π¨ + π’ π¨ 0 0 1 π’ π¨ 1 1 0 0 0 1 y T (2,1)B B x
Recommend
More recommend