computer graphics
play

Computer Graphics - Transformations - Philipp Slusallek Vector - PowerPoint PPT Presentation

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


  1. Computer Graphics - Transformations - Philipp Slusallek

  2. 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 ∈ ℝ

  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(πœ„)

  4. 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

  5. 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 – 𝑒𝑗𝑑𝑒 𝑏, 𝑐 = 𝑏 βˆ’ 𝑐

  6. 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

  7. 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

  8. 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

  9. 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 β€’ π‘Όπ‘ž = 𝑼 𝛽 𝑗 π‘ž 𝑗 = 𝑩 𝛽 𝑗 π‘ž 𝑗 + 𝒖 = 𝛽 𝑗 (π‘©π‘ž 𝑗 ) + 𝛽 𝑗 𝒖 = 𝛽 𝑗 (π‘Όπ‘ž 𝑗 )

  10. 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)

  11. 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 𝑦 = π‘Œ 𝑧 = 𝑍 𝑋 𝑋

  12. 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 β€’ π‘Œ ∈ π‘š ∩ π‘š β€² ⇔ π‘Œ = π‘š Γ— π‘šβ€²

  13. 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

  14. Line Representation β€’ Line – Represented by normal vector to plane through line and origin π‘š = (𝑏, 𝑐, 𝑑) 𝑏𝑦 + 𝑐𝑧 + 𝑑 β‹… 1 = 0

  15. Line through 2 Points β€’ Construct line through two points – Line vector must be orthogonal to both points – Compute through cross product of point coordinates π‘ž = (π‘Œ, 𝑍, 𝑋) π‘žβ€² = (π‘Œ, β€² 𝑍, β€² 𝑋′) π‘š = (𝑏, 𝑐, 𝑑) π‘š = π‘ž Γ— π‘žβ€²

  16. 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 π‘ž π‘šβ€² π‘š π‘ž = π‘š Γ— π‘šβ€²

  17. 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 ≔ 𝑁 π‘ˆ

  18. 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)

  19. 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:

  20. 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend