Computer Graphics WS07/08 – Transformations
Computer Graphics
- Transformations -
Computer Graphics - Transformations - Hendrik Lensch Computer - - PowerPoint PPT Presentation
Computer Graphics - Transformations - Hendrik Lensch Computer Graphics WS07/08 Transformations Overview Last Time Tone Mapping Today Homogeneous Coordinates Basic transformations in homogeneous coordinates
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
– Tone Mapping
– Homogeneous Coordinates – Basic transformations in homogeneous coordinates – Concatenation of transformations – Projective transformations
– Camera transformations
Computer Graphics WS07/08 – Transformations
– Elements of a 3D vector space
– Formally: Vectors written as column vectors (n x 1 matrix)! – Vectors describe directions – not positions! – 3 linear independent vectors create a basis:
– Any vector can now uniquely be represented with coordinates
– Operations
– Dot/inner product:
and angles (cos(v1, v2)= v1 · v2 / | v1||v2|)
– Orthonormal basis
ei · ej =δij right-/left handed: e1 × e2 = +/- e3 e e1
1
e e2
2
e e3
3
Computer Graphics WS07/08 – Transformations
– Affine Space: A3
– Defined via its associated vector space V3
→: unique, ←: ambiguous – Addition of points and vectors (p + v ∈ A3)
– Operations on A3
b a a v v
Computer Graphics WS07/08 – Transformations
– {o, e1, e2, e3}
– Position vector of point p
e1
1
e e2
2
e e3
3
Computer Graphics WS07/08 – Transformations
– Linear combination of (n+1) points – Weights form a partition of unity – b0, … , bn ∈ An
– Barycentric coordinates – Center of mass (R = Σ mi ri / Σ mi) – Affine weighted sum
– p= α1p1 + α2p2 α1+ α2= 1
1 1
= = = i n i i i n i i i n i i i
p p2
2
p p1
1
p p α α2
2
α α1
1
Computer Graphics WS07/08 – Transformations
– Affine mapping (continuous, bijective, invertible)
– Defined by two non-degenerated simplicies
– Affine/Barycentric coordinates are invariant under affine transformations – Other invariants
– Characterization via fixed points and lines
– Linear mapping A plus a translation t
with (n x n) matrix A
– Invariance of affine coordinates
α1A(p1) + α2A(p2) + α1t + α2t = α1Tp1 + α2 T( p2) p p2
2
p p1
1
p p α α2
2
α α1
1
Computer Graphics WS07/08 – Transformations
– For the time being – Representation of transformations by 4x4 matrices – Mathematical trick
as matrix multiplications
– Also important for projections (later)
4 3
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
l=(a,b,c) X=(X,Y,W)
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
l=(a,b,c) X=(X,Y,W) X’=(X’,Y’,W’)
Computer Graphics WS07/08 – Transformations
– Action of a linear map on a vector
– Composition (first T1, then T2)
ww wz wy wx zw zz zy zx yw yz yy yx xw xz xy xx
Computer Graphics WS07/08 – Transformations
z z y y x x z y x z y x
z y x z y x
Computer Graphics WS07/08 – Transformations
– Which is exactly what we expect to happen
z z y y x x z y x z y x
v v v v v v v d d d v
z y x z y x z y x
= ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 1 1 1 T
Computer Graphics WS07/08 – Transformations
– T(0,0,0)= 1 (Identity Matrix) – T(tx, ty, tz) T(tx’, ty’,tz’) = T(tx + tx’, ty + ty’, tz + tz’) – T(tx, ty, tz) T(tx’, ty’,tz’) = T(tx’, ty’,tz’) T(tx, ty, tz) – T-1(tx, ty, tz) = T(-tx, -ty, -tz)
Computer Graphics WS07/08 – Transformations
ϕ ϕ ϕ θ ϕ θ ϕ ϕ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ θ θ cos sin cos ) sin ( sin ) cos ( ' sin cos sin ) sin ( cos ) cos ( ' cos sin sin cos ) sin( sin sin cos cos ) cos( ) sin( ' ) cos( ' sin cos y x r r y y x r r x r y r x r y r x + = + = − = − = + = + − = + + = + = = =
r cosθ r sinθ r cos(θ+ϕ) r sin(θ+ϕ) θ θ+ϕ x y
Computer Graphics WS07/08 – Transformations
– Assumes a right handed coordinate system
x
y
z
Computer Graphics WS07/08 – Transformations
– Ra(0)= 1 – R-1
a(θ) = Ra(-θ)
– Ra(θ) Ra(ϕ) = Ra(θ + ϕ) – Ra(θ) Ra(ϕ) = Ra(ϕ) Ra(θ) – R-1
a(θ) = Ra(-θ) = RT a(θ)
– BUT in general: Ra(θ) Rb(ϕ) ≠ Rb(ϕ) Ra(θ)
Computer Graphics WS07/08 – Transformations
– Uniform Scaling
z y x z y x
Computer Graphics WS07/08 – Transformations
– Warning: Change of orientation !
z
p1 p2 p3 p3 p1 p2
Computer Graphics WS07/08 – Transformations
zy zx yz yx xz xy zy zx yx yz xz xy
H(1,0,0,0,0,0)
Computer Graphics WS07/08 – Transformations
R(45) T(1,1) R(45) T(1,1) R(45) T(1,1)
Computer Graphics WS07/08 – Transformations
– Translate object from point to origin – Apply desired rotation – Translate object back to original position
⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − − − ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − − − ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡
− −
1 1 cos sin cos sin sin cos sin cos 1 1 1 1 1 1 cos sin sin cos 1 1 1 1
y y x x y x p a p p a z y x z y x p a p p a
p θ p + θ p θ θ p θ p θ p θ θ = T θ R T = θ R p p p θ θ θ θ p p p = T θ R T = θ R
Computer Graphics WS07/08 – Transformations
– Move base point to origin
– Rotation around Y-axis, so that r is in YZ-plane
– Rotation around X-axis, so that r’ is along Z-axis
– Rotation around Z-axis with angle ϕ – Rotate back around X-axis – Rotate back around Y-axis – Translate back
– R(ϕ, o, r) = T(o)Ry(ϕ1)Rx(-ϕ2)Rz(ϕ)Rx(ϕ2)Ry(-ϕ1)T(-o)
x z x y z ϕ ϕ1
1
y z ϕ ϕ2
2
y x rx rz ry rz
Computer Graphics WS07/08 – Transformations
– Simple: Write new basis vectors into columns of matrix
z y x
ww wz wy wx zw zz zy zx yw yz yy yx xw xz xy xx
x y z x’ y’ z’
Computer Graphics WS07/08 – Transformations
– Images of basis vectors are again orthonormal
Which means that
z z y z x z z y y y x y z x y x x x z y x T z y x T
1 −
Computer Graphics WS07/08 – Transformations
– Transform end points
– Transform three points
– v = p – q = (x, z, y, 0)T – Translations to not act on vectors
– Problem: e.g. with non-uniform scaling
Computer Graphics WS07/08 – Transformations
– For any vector T in the plane: NT * T = 0 – Find transformation M’ for normal vector, such that
z y x z y x T
Matrix multiplication Dot product
T T T T T
1 −
Computer Graphics WS07/08 – Transformations
Normals are transformed by the transpose of the inverse of the 4x4 transformation matrix of points and vectors
– E.g. rotation, uniform scaling
Computer Graphics WS07/08 – Transformations
– Defined by the normal, tangent and bi-normal at each point of a surface – Transformation of BRDFs
– Intrinsic coordinate system of an object – Hierarchical modeling – Modeling Transformations to world coordinates
– Root for hierarchical modeling – Reference system for the camera – Viewing Transformation to camera coordinates
– Reference system for lighting computations – Perspective Transformation to normalized (projection) coordinates
Computer Graphics WS07/08 – Transformations
body torso head shoulder larm upperarm lowerarm hand rarm upperarm lowerarm hand hips lleg upperleg lowerleg foot rleg upperleg lowerleg foot
3 1 1 2 2 2 2 2 2 2 2 1.5 1.5
Translate 0 4 0 TransformBegin # Draw Torso Translate 0 3 0 # Draw Shoulders TransformBegin Rotate a 0 0 1 # Draw head TransformEnd TransformBegin Translate 1.5 0 0 DRAW_ARM(a,b,c) TransformEnd TransformBegin Translate –1.5 0 0 DRAW_ARM(d,e,f) TransformEnd TransformEnd # Draw hips TransformBegin TransformBegin Translate 1 0 0 DRAW_LEG(g,h) TransformEnd TransformBegin Translate -1 0 0 DRAW_LEG(i,j) TransformEnd TransformEnd DRAW_ARM(a,b,c) { Rotate b 0 0 1 # Draw upperarm Translate 0 -2 0 Rotate c 1 0 0 # Draw lowerarm Translate 0 -2 0 # Draw hand } DRAW_LEG(g,h) { Rotate g 1 0 0 # Draw upperleg Translate 0 –2 0 Rotate h 1 0 0 # Draw lowerleg Translate 0 –2 0 # Draw foot }
Computer Graphics WS07/08 – Transformations
– Mapping from 3D to 2D – Results in loss of information – Non invertible
– Projection along lines onto a projection plane – Perspective projection (central projection)
– Special case: Orthographic projection
View point/ center
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
– Parallel/orthographic projection – Projection plane orthogonal to projection direction
– Projektion direction has same angle with every coordinate axis
Computer Graphics WS07/08 – Transformations
– Same angle with 2 axes
– Same angle with one axis
Computer Graphics WS07/08 – Transformations
– Parallel projection – Projektion plane parallel to two coordinate axes (e.g. x, y) – Projection direction not orthogonal to plane
– Same length on all axes
z
Computer Graphics WS07/08 – Transformations
– Foreshortening of ½ orthogonal to projection plane
– Shearing plus parallel projection
z x
Computer Graphics WS07/08 – Transformations
– Projection onto plane along lines through a projection point – Parallel lines do NOT stay parallel
– Projections of intersection points axis-parallel lines at infinity – N-point perspective
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
Computer Graphics WS07/08 – Transformations
⇒ line orientation is preserved
⇒ parallel lines remain parallel
⇒ parallel lines converge