Philipp Slusallek
Computer Graphics
- Transformations -
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
β 3D vector space over the real numbers
π€1 π€2 π€3 β πΎπ = βπ
β Vectors written as n x 1 matrices β Vectors describe directions β not positions!
β 3 linear independent vectors create a basis
π1, π2, π3 = 1 , 1 , 1
β Any 3D vector can be represented uniquely with coordinates π€π
π€1, π€2, π€3 β β e1 e2 e3
β Measure lengths
2 + π€2 2 + π€3 2
β Compute angles
β Projection of vectors onto other vectors
π€ = π£β π€ π€β π€
u v Ι΅ π£ cos(π)
β Unit length vectors
β Orthogonal to each other
π = πππ
β Two options: π1 Γ π2 = Β±π3
Right-handed (RHS)
β Example: Screen Space
β Be careful:
β Denoted as A3
β Defined via its associated vector space V3
β Operations on A3
β Its not clear what the some of two points would mean
β π + π€ = π β π΅3
β πππ‘π’ π, π = π β π
v b a
β Given by its origin o (a point) and the basis of an associated vector space
ππ, ππ, ππ β π3; π β π©π
β (π β π) is in π3
e1 e2 e3
p-o
β Linear combination of (n+1) points
β With weights forming a partition of unity
β π = π=0
π
π½πππ = π0 + π=1
π
π½π(ππ β π0) = π + π=1
π
π½ππ€π
β (π + 1) points form am affine basis of π΅π
the other points
combination of the affine basis π0, β¦ , ππ β π΅π
combination of the ππ, yielding a matrix for the basis
β Center of mass of (π + 1) points with arbitrary masses (weights) ππ is given as
ππππ ππ = ππ ππ ππ = π½πππ
β If all π½π are non-negative than p is in the convex hull
β Point is defined by the splitting ratio π½1: π½2
πβπ2 π2βπ1 π1 + πβπ1 π2βπ1 π2
β Weights are the relative areas in Ξ(π΅1, π΅2, π΅3)
Ξ(π,π΅ π+1 %3,π΅ π+2 %3) Ξ(π΅1,π΅2,π΅3)
p p1 p2
π΅1 π΅2 π΅3
Note: Length and area measures are signed here
β Affine mapping (continuous, bijective, invertible)
β Defined by two non-degenerated simplicies
β Invariants under affine transformations:
β Characterization via fixed points and lines
β Matrix product and a translation vector:
β Invariance of affine coordinates
space P(R4)
β Mapping into homogeneous space
π¦ π§ π¨ βΆ π¦ π§ π¨ 1 β π β4
β Mapping back by dividing through fourth component
π π π βΆ π/π π/π π/π
β This allows to represent affine transformations as 4x4 matrices β Mathematical trick
matrix multiplications
β Also important for projections (later)
β All points along a line through the origin map to the same point in 2D
β Point representation
π π π β π β3 , π¦ π§ = π π π π
β Representation of a line π β β2
β π = π¦ π§ ππ¦ + ππ§ + π β 1 = 0 = π β π(β3) π β π = 0, l= π π π
β Line trough 2 points p and pβ
β Intersection of lines l and lβ:
β Set of all point P where the dot product with l is zero π = (π, π, π) π = (π, π, π)
π β π = 0
β Represented by normal vector to plane through line and origin π = (π, π, π)
ππ¦ + ππ§ + π β 1 = 0
β Line vector must be orthogonal to both points β Compute through cross product of point coordinates π = (π, π, π) π = (π, π, π) πβ² = (π, β² π, β² πβ²)
π = π Γ πβ²
β A point that is on both lines and thus orthogonal to both lines
π = π Γ πβ²
β An example
1 1
β Directly derived from the definition of the matrix product:
β In this case the transpose must be identical to the inverse:
β Action of a linear transformation on a vector
πβ² = πβ² πβ² πβ² = πΌπ = π
π¦π¦
π
π¦π§
π
π¦π¨
π
π§π¦
π
π§π§
π
π§π¨
π
π¨π¦
π
π¨π§
π
π¨π¨
π π π
β Simple matrix multiplication (πΌπ, then πΌπ)
β Note: matrix multiplication is associative but not commutative!
β Affine map: Linear mapping and a translation
β Using homogeneous 4D coordinates β Multiplication by 4x4 matrix in P(R4) space
πβ² πβ² πβ² πβ² = ππ = π
π¦π¦
π
π¦π§
π
π¦π¨
π
π¦π₯
π
π§π¦
π
π§π§
π
π§π¨
π
π§π₯
π
π¨π¦
π
π¨π§
π
π¨π¨
π
π¨π₯
π
π₯π¦
π
π₯π§
π
π₯π¨
π
π₯π₯
π π π π
β Allows for combining (concatenating) multiple transforms into one using normal (4x4) matrix products
β πΌ π’π¦, π’π§, π’π¨ π = 1 π’π¦ 1 π’π§ 1 π’π¨ 1 π¦ π§ π¨ 1 = π¦ + π’π¦ π§ + π’π§ π¨ + π’π¨ 1
T(2,1)B B x y
β π€ = π β π = ππ¦ ππ§ ππ¨ 1 β ππ¦ ππ§ ππ¨ 1 = ππ¦ β ππ¦ ππ§ β ππ§ ππ¨ β ππ¨ β Fourth component is zero
1 π’π¦ 1 π’π§ 1 π’π¨ 1 π€π¦ π€π§ π€π¨ = π€π¦ π€π§ π€π¨
β Identity
β Commutative (special case)
β² , π’π§ β² , π’π¨ β²
= πΌ π’π¦
β² , π’π§ β² , π’π¨ β² πΌ π’π¦, π’π§, π’π¨ =
πΌ(π’π¦ + π’π¦
β² , π’π§ + π’π§ β² , π’π¨ + π’π¨ β²)
β Inverse
β² , βπ’π§ β² , βπ’π¨ β²
β π π‘π¦, π‘π§, π‘π¨ = π‘π¦ π‘π§ π‘π¨ 1 β Note: π‘π¦, π‘π§, π‘π¨ β₯ 0 (otherwise see mirror transformation) β Uniform Scaling s: s = π‘π¦ = π¦π§ = π‘π¨
B x y S(2,1)B x y
β Reflection at plane (x=0)
β1 1 1 1 π¦ π§ π¨ 1 = βπ¦ π§ π¨ 1
β Right-handed rotation becomes left-handed and v.v. β Indicated by det ππ < 0
β Reflection at origin
β1 β1 β1 1 π¦ π§ π¨ 1 = βπ¦ βπ§ βπ¨ 1
β But not in 2D (!!!): Just two scale factors β Each scale factor reverses orientation once
B x y Mx B B x y Mo B
a a b b c c a b c a b c
β π° βπ¦π§, βπ¦π¨, βπ§π¨, βπ§π¦, βπ¨π¦, βπ¨π§ = 1 βπ¦π§ βπ¦π¨ βπ§π¦ 1 βπ§π¨ βπ¨π¦ βπ¨π§ 1 1 π¦ π§ π¨ 1 = π¦ + βπ¦π§π§ + βπ¦π¨π¨ π§ + βπ§π¦π¦ + βπ§π¨π¨ π¨ + βπ¨π¦π¦ + βπ¨π§π§ 1 β Determinant is 1
B x y H(1,0,0,0,0,0)B x y
β Representation in spherical coordinates
π§ = π sin π βΆ π§β² = π sin(π + π)
β Well know property
sin π + π = cos π sin π + sin π cos π
β Gives
π§β² = π cos π sin π + π sin π cos π = π¦ sin π + π§ cos π
β Or in matrix form
βsin π sin π cos π R(90Β°)B B x y x y Ι΅ ΙΈ xβ yβ
β πΊπ π = 1 cos π βsin π sin π cos π 1 β πΊπ π = cos π sin π 1 β sin π cos π 1 β πΊπ π = cos π βsin π sin π cos π 1 1 β 2D rotation around the respective axis
β Be aware of change in sign on sines in πΊπ
β πΊπ 0 = π β πΊπ π πΊπ π = πΊπ π + π = πΊπ π πΊπ π
β In general: Not commutative
β πΊπ
βπ π = πΊπ βπ = πΊπ πΌ π
β Determinant is 1
β Translate p to origin, rotate around axis a, translate back to p
B x y p Bβ= T(-p)B x y p Bββ= Rz(ΙΈ)Bβx y p T(p)Bββ x y p
β Translate so that p is in the origin β Transform with rotation R=MT
β Rotate around x axis β Transform back with R-1 β Translate back to point p
x y z r t s x y z r t s x y z r t MT M π π, π , π = π(π)π(π )ππ¦ π ππ(π )T(βp) s
Figure without translation aspect
β Using a numerically stable method β Construct s such that it is normal to r (verify with dot product)
β Do this in coordinate plane that has largest components
0, βπ
π¨, π π§ , if π¦ = argminπ¦,π§,π¨ π π¦ , π π§ , π π¨
βπ
π¨, 0, π π¦ , if π§ = argminπ¦,π§,π¨ π π¦ , π π§ , π π¨
βπ
π§, π π¦, 0 , if π¨ = argminπ¦,π§,π¨ π π¦ , π π§ , π π¨
β Normalize
π‘β² π‘β²
β Compute t as cross product
β r,s,t forms orthonormal basis, thus M transforms into this basis
π
π¦
π‘π¦ π’π¦ π
π§
π‘π§ π’π§ π
π¨
π‘π¨ π’π¨ 1 , inverse is given as its transpose: πβ1 = ππ
β Matrix-matrix multiplication is not commutative (in general) β Order of transformations matters!
B x y T(1,1)B x y Rz(45Β°)B x y Rz(45Β°) T(1,1)B x y T(1,1)Rz(45Β°)B x y
β Transform end points
β Transform three points
β Translations to not act on vectors
β Problem: e.g. with non-uniform scaling
B x y n S(2,1,1)B x y S(2,1,1)n S(2,1,1)
β π β π€ = πππ€ = ππ¦ ππ§ ππ¨ π€π¦ π€π§ π€π¨
β For any vector π€ in the plane: πππ€ = 0 β Find transformation π΅β for normal vector, such that :
ππ π΅β²ππ΅ π€ = 0 π΅β²ππ΅ = 1 and thus π΅β²ππ΅π΅β1 = 1π΅β1 π΅β²π = π΅β1 π΅β² = (π΅β1)π
β π΅β is the adjoint of π΅
β Normals are transformed by the transpose of the inverse of the 4x4 transformation matrix of points and vectors