Computer Graphics - Transformations - Hendrik Lensch Computer - - PowerPoint PPT Presentation

computer graphics
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Computer Graphics WS07/08 – Transformations

Computer Graphics

  • Transformations -

Hendrik Lensch

slide-2
SLIDE 2

Computer Graphics WS07/08 – Transformations

Overview

  • Last Time

– Tone Mapping

  • Today

– Homogeneous Coordinates – Basic transformations in homogeneous coordinates – Concatenation of transformations – Projective transformations

  • Next Lecture

– Camera transformations

slide-3
SLIDE 3

Computer Graphics WS07/08 – Transformations

Euclidean Vector Space

  • Known from Mathematics:

– Elements of a 3D vector space

  • v = (v1, v2, v3)T ∈ V3 = R3

– Formally: Vectors written as column vectors (n x 1 matrix)! – Vectors describe directions – not positions! – 3 linear independent vectors create a basis:

  • {e1, e2, e3}

– Any vector can now uniquely be represented with coordinates

  • v = v1 e1 + v2 e2 + v3 e3 = (v1, v2, v3)T

– Operations

  • Addition, Subtraction, Scaling, …
  • Metric

– Dot/inner product:

  • Used for measurements of length (|v|2= v · v)

and angles (cos(v1, v2)= v1 · v2 / | v1||v2|)

– Orthonormal basis

  • |ei|= 1

ei · ej =δij right-/left handed: e1 × e2 = +/- e3 e e1

1

e e2

2

e e3

3

slide-4
SLIDE 4

Computer Graphics WS07/08 – Transformations

Affine Space

  • Known from Mathematics

– Affine Space: A3

  • Elements are positions – no directions!

– Defined via its associated vector space V3

  • a, b ∈ A3 ⇔ v ∈ V3 with v = b – a

→: unique, ←: ambiguous – Addition of points and vectors (p + v ∈ A3)

  • distance(a, b) = length(a - b)

– Operations on A3

  • Subtraction yields a vector
  • No addition of affine elements

b a a v v

slide-5
SLIDE 5

Computer Graphics WS07/08 – Transformations

Affine Basis

  • Affine Basis:

– {o, e1, e2, e3}

  • Origin: o ∈ A3 and
  • Basis of vector space

– Position vector of point p

  • (p – o) ∈ V3
  • e

e1

1

e e2

2

e e3

3

slide-6
SLIDE 6

Computer Graphics WS07/08 – Transformations

Affine Coordinates

  • Affine Combination

– Linear combination of (n+1) points – Weights form a partition of unity – b0, … , bn ∈ An

  • Affine Coordinates

– Barycentric coordinates – Center of mass (R = Σ mi ri / Σ mi) – Affine weighted sum

  • Weights given by the splitting ratio

– p= α1p1 + α2p2 α1+ α2= 1

1 mit , ) (

1 1

= + = − + = =

∑ ∑ ∑ ∑

= = = i n i i i n i i i n i i i

e

  • b

b b b b α α α α

p p2

2

p p1

1

p p α α2

2

α α1

1

slide-7
SLIDE 7

Computer Graphics WS07/08 – Transformations

Affine Mappings

  • Properties

– Affine mapping (continuous, bijective, invertible)

  • T: A3 → A3

– Defined by two non-degenerated simplicies

  • 2D: Triangle, 3D: Tetrahedron, ...

– Affine/Barycentric coordinates are invariant under affine transformations – Other invariants

  • Straight lines, parallelism, splitting ratios, surface/volume ratios

– Characterization via fixed points and lines

  • Eigenvalues and eigenvectors of the mapping
  • Representation

– Linear mapping A plus a translation t

  • Tp = A p + t

with (n x n) matrix A

– Invariance of affine coordinates

  • Tp= T(α1p1 + α2p2)= A(α1p1 + α2p2) + t =

α1A(p1) + α2A(p2) + α1t + α2t = α1Tp1 + α2 T( p2) p p2

2

p p1

1

p p α α2

2

α α1

1

slide-8
SLIDE 8

Computer Graphics WS07/08 – Transformations

Homogeneous Coordinates for 3D

  • Embedding of R3 into P(R4)

– For the time being – Representation of transformations by 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)

⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ → ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ∈ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ → ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ ∋ W Z W Y W X W Z Y X z y x z y x R / / / and ), P(R 1

4 3

slide-9
SLIDE 9

Computer Graphics WS07/08 – Transformations

Point Representation

(x,y) X=(X,Y,W) w=1 W Y = y W X = x

slide-10
SLIDE 10

Computer Graphics WS07/08 – Transformations

Line Representation

ax+by+c=0

l=(a,b,c)

slide-11
SLIDE 11

Computer Graphics WS07/08 – Transformations

Point on Line

= ⋅l x

l=(a,b,c) X=(X,Y,W)

slide-12
SLIDE 12

Computer Graphics WS07/08 – Transformations

Intersection of Lines

x l l = × '

l l’ x

slide-13
SLIDE 13

Computer Graphics WS07/08 – Transformations

Line through 2 Points

l=(a,b,c) X=(X,Y,W) X’=(X’,Y’,W’)

l x x = × '

slide-14
SLIDE 14

Computer Graphics WS07/08 – Transformations

Linear Map = Matrix

  • Vector Matrix Product

– Action of a linear map on a vector

  • Multiplication of matrix with column vector
  • In some old text books: row vector times the transpose of this matrix

– Composition (first T1, then T2)

  • Matrix multiplication
  • T2T1 p = T2(T1 p) = (T2T1) p = T p
  • Warning: In general, matrix multiplication does not commute !!!

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = w z y x t t t t t t t t t t t t t t t t w z y x T p T w z y x p

ww wz wy wx zw zz zy zx yw yz yy yx xw xz xy xx

' ' ' ' '

slide-15
SLIDE 15

Computer Graphics WS07/08 – Transformations

Basic Transformations

  • Translation

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ + + + = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 1 1 1 1 1

z z y y x x z y x z y x

d p d p d p p p p d d d p T ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 1 1 1 ) , , (

z y x z y x

d d d d d d T

slide-16
SLIDE 16

Computer Graphics WS07/08 – Transformations

Translation of Vectors

  • So far we looked at points (affine entities)
  • Vectors are defined as the difference of two points
  • Consequently, for vectors W is always equal to zero
  • This means that translations DO NOT act on vectors

– Which is exactly what we expect to happen

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − − − = ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = − = 1 1

z z y y x x z y x z y x

q p q p q p q q q p p p q p v

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

slide-17
SLIDE 17

Computer Graphics WS07/08 – Transformations

Translations

  • Properties

– 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)

slide-18
SLIDE 18

Computer Graphics WS07/08 – Transformations

Rotation

  • Rotation in 2D

ϕ ϕ ϕ θ ϕ θ ϕ ϕ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ ϕ θ θ θ 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

slide-19
SLIDE 19

Computer Graphics WS07/08 – Transformations

Basic Transformations

  • Rotation around major axis

– Assumes a right handed coordinate system

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − = 1 cos sin sin cos 1 ) ( θ θ θ θ θ

x

R ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − = 1 cos sin 1 sin cos ) ( θ θ θ θ θ

y

R ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − = 1 1 cos sin sin cos ) ( θ θ θ θ θ

z

R

slide-20
SLIDE 20

Computer Graphics WS07/08 – Transformations

Rotation

  • Properties

– 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(θ)

  • For rotations around different axes, the order matters
slide-21
SLIDE 21

Computer Graphics WS07/08 – Transformations

Basic Transformations

  • Scaling

– Uniform Scaling

  • sx= sy = sz

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 ) , , (

z y x z y x

s s s s s s S

slide-22
SLIDE 22

Computer Graphics WS07/08 – Transformations

Basic Transformations

  • Reflection at Z

– Warning: Change of orientation !

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − = 1 1 1 1

z

M

p1 p2 p3 p3 p1 p2

slide-23
SLIDE 23

Computer Graphics WS07/08 – Transformations

Basic Transformations

  • Shear (deutsch: Scherung)

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 1 1 1 ) , , , , , (

zy zx yz yx xz xy zy zx yx yz xz xy

h h h h h h h h h h h h H

H(1,0,0,0,0,0)

slide-24
SLIDE 24

Computer Graphics WS07/08 – Transformations

Concatenation of Transformations

  • In general, transformations do not commute

R(45) T(1,1) R(45) T(1,1) R(45) T(1,1)

slide-25
SLIDE 25

Computer Graphics WS07/08 – Transformations

Rotation about Arbitrary Points

  • Example: Rotate object about one vertex p

– 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

slide-26
SLIDE 26

Computer Graphics WS07/08 – Transformations

Rotation about Arbitrary Axis

– Move base point to origin

  • T(-o)

– Rotation around Y-axis, so that r is in YZ-plane

  • Use projection into XZ-plane
  • Ry(-ϕ1) tan(ϕ1)= rx/rz r'= Ry(-ϕ1) r

– Rotation around X-axis, so that r’ is along Z-axis

  • Rx(ϕ2) tan(ϕ2)= r’y/ rz’

– Rotation around Z-axis with angle ϕ – Rotate back around X-axis – Rotate back around Y-axis – Translate back

  • Together

– R(ϕ, o, r) = T(o)Ry(ϕ1)Rx(-ϕ2)Rz(ϕ)Rx(ϕ2)Ry(-ϕ1)T(-o)

  • r

x z x y z ϕ ϕ1

1

y z ϕ ϕ2

2

y x rx rz ry rz

slide-27
SLIDE 27

Computer Graphics WS07/08 – Transformations

Interpretation of Matrices

  • Columns are transformed basis
  • Transformation into new basis

– Simple: Write new basis vectors into columns of matrix

( )

M

  • e

e e

z y x

= ' ' ' '

⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 , 1 , 1 ,

  • der

1 '

ww wz wy wx zw zz zy zx yw yz yy yx xw xz xy xx

t t t t t t t t t t t t t t t t p

x y z x’ y’ z’

slide-28
SLIDE 28

Computer Graphics WS07/08 – Transformations

Orthonormal Matrices

  • Orthonormal transformations

– Images of basis vectors are again orthonormal

  • ei’ · ej’ = δij

Which means that

( ) ( )

1 M M = ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ = = = ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '

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

e e e e e e e e e e e e e e e e e e e e e e e e

1 −

= M MT

slide-29
SLIDE 29

Computer Graphics WS07/08 – Transformations

Transformations

  • Line

– Transform end points

  • Plane

– Transform three points

  • Vector

– v = p – q = (x, z, y, 0)T – Translations to not act on vectors

  • Normal vectors

– Problem: e.g. with non-uniform scaling

slide-30
SLIDE 30

Computer Graphics WS07/08 – Transformations

Transforming Normals

  • Dot product as matrix multiplication
  • Normal N on a plane

– 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

w w w v v v w v w v * ) , , ( *

Matrix multiplication Dot product

T T T T T

T N T N ) ( ' 1 * ' * ) * ' ( * ) * ( * ) '* (

1 −

= = = = M M M M M M M M

slide-31
SLIDE 31

Computer Graphics WS07/08 – Transformations

Transforming Normals

  • Remember:

Normals are transformed by the transpose of the inverse of the 4x4 transformation matrix of points and vectors

  • No problem with orthogonal transformations

– E.g. rotation, uniform scaling

  • M-1 = MT
  • M-1T = MTT = M
slide-32
SLIDE 32

Computer Graphics WS07/08 – Transformations

Coordinate Systems

  • Local Coordinates

– Defined by the normal, tangent and bi-normal at each point of a surface – Transformation of BRDFs

  • Object Coordinates

– Intrinsic coordinate system of an object – Hierarchical modeling – Modeling Transformations to world coordinates

  • World Coordinates

– Root for hierarchical modeling – Reference system for the camera – Viewing Transformation to camera coordinates

  • Camera coordinates (Viewing Coordinates)

– Reference system for lighting computations – Perspective Transformation to normalized (projection) coordinates

slide-33
SLIDE 33

Computer Graphics WS07/08 – Transformations

Hierarchical Coordinate Systems

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 }

RenderMan Syntax scene graph: graph of transformations, attributes and primitives

slide-34
SLIDE 34

Computer Graphics WS07/08 – Transformations

Projections

  • Definition: Projection

– Mapping from 3D to 2D – Results in loss of information – Non invertible

  • Planar perspective projections

– Projection along lines onto a projection plane – Perspective projection (central projection)

  • Lines intersect in a single point

– Special case: Orthographic projection

  • Parallel lines
  • View point at infinity

View point/ center

slide-35
SLIDE 35

Computer Graphics WS07/08 – Transformations

Classification of Projections

slide-36
SLIDE 36

Computer Graphics WS07/08 – Transformations

Axonometric Projection

  • Properties

– Parallel/orthographic projection – Projection plane orthogonal to projection direction

  • Isometric Projection

– Projektion direction has same angle with every coordinate axis

  • Lengths are maintained
slide-37
SLIDE 37

Computer Graphics WS07/08 – Transformations

Axonometric Projection

  • Dimetric and Trimetric Projection

– Same angle with 2 axes

  • Two lengths are maintained, one is scaled

– Same angle with one axis

  • One length is maintained, two are scaled
slide-38
SLIDE 38

Computer Graphics WS07/08 – Transformations

Oblique Projection

  • Properties

– Parallel projection – Projektion plane parallel to two coordinate axes (e.g. x, y) – Projection direction not orthogonal to plane

  • Cavalier Projection

– Same length on all axes

z

slide-39
SLIDE 39

Computer Graphics WS07/08 – Transformations

Oblique Projection

  • Cabinet Projection

– Foreshortening of ½ orthogonal to projection plane

  • Implementation of Oblique Projections

– Shearing plus parallel projection

z x

slide-40
SLIDE 40

Computer Graphics WS07/08 – Transformations

Planar Perspective Projection

  • Properties

– Projection onto plane along lines through a projection point – Parallel lines do NOT stay parallel

  • Not an affine transformation
  • Vanishing point

– Projections of intersection points axis-parallel lines at infinity – N-point perspective

  • Details later
slide-41
SLIDE 41

Computer Graphics WS07/08 – Transformations

Projective Transformations in 3D

slide-42
SLIDE 42

Computer Graphics WS07/08 – Transformations

Taxonomy of Projective Transformations

slide-43
SLIDE 43

Computer Graphics WS07/08 – Transformations

Distortions under Central Projection

  • Similarity: circle remains circle, square remains square

⇒ line orientation is preserved

  • Affine: circle becomes ellipse, square becomes rhombus

⇒ parallel lines remain parallel

  • Projective: imaged object size depends on distance from camera

⇒ parallel lines converge