of 21 /21
Examples: Affine and Projective Transformation Matrices Ron Goldman Department of Computer Science Rice University

others
• Category

## Documents

• view

7

0

Embed Size (px)

### Transcript of Examples: Affine and Projective Transformation Matrices

Examples:Affine and Projective Transformation Matrices

Ron GoldmanDepartment of Computer ScienceRice University

Affine Transformation Matrices

Typical Affine Transformation (Vectors)

vnew = c1vold + c2 (vold •w1)w2 +c3(w3 × vold )

3× 3 Matrix Formulation

M(w1,w2 ,w3) = c1I + c2 (w1⊗w2 )+c3(w3 × _)

vnew = vold ∗M (w1,w2,w3)

Typical Affine Transformation (Points)Q = fixed point

P = Q + (P −Q)

Pnew = Q+ (Pold −Q)∗M (w1,w2,w3)

4 × 4 Matrix Formulation

M(w1,w2 ,w3,Q) =M (w1,w2,w3) 0

Q−Q∗M (w1,w2,w3) 1

Rotation Matrices

Rotation (Vectors)

vnew = cos(ϑ)vold + 1− cos(ϑ )( )(vold •w)w + sin(ϑ )(w× vold ) ↓ ↓ ↓R(w,ϑ ) = cos(ϑ )I + 1− cos(ϑ )( )w⊗w + sin(ϑ )(w × _)

4 × 4 Rotation Matrix

R(w,ϑ ,Q) =R(w,ϑ ) 0

Q −Q∗R(w,ϑ ) 1

Rotation Around the z–Axis

L = z–Axis•

w = k = 0 0 1( )•

Q = Origin = 0 0 0( )

Matrices

I =

1 0 00 1 00 0 1

k ⊗ k =

0 0 00 0 00 0 1

k× =

0 1 0−1 0 00 0 0

Rotation Around the z–Axis (continued)

3× 3 Rotation Matrix

R(k,θ) = cos(θ)I + 1− cos(θ)( )k ⊗ k + sin(θ)k ×

R(k,θ) = cos(θ)1 0 00 1 00 0 1

+ 1− cos(θ)( )

0 0 00 0 00 0 1

+ sin(θ)

0 1 0−1 0 00 0 0

R(k,θ) =

cos(θ) 0 00 cos(θ) 00 0 cos(θ)

+

0 0 00 0 00 0 1− cos(θ)

+

0 sin(θ) 0− sin(θ) 0 0

0 0 0

R(k,θ) =

cos(θ) sin(θ) 0− sin(θ) cos(θ) 0

0 0 1

Rotation Around the z–Axis (continued)

4 × 4 Rotation Matrix

R(k,θ,Origin) =R(k,θ) 0

Origin−Origin∗R(k,θ) 1

R(k,θ,Q) =

cos(θ) sin(θ) 0 0−sin(θ) cos(θ) 0 0

0 0 1 00 0 0 1

Rotation Around the x,y–Axes (Exercise)

Rotation Around x–Axis

R(i,θ ,Origin) =

1 0 0 00 cos(θ) sin(θ) 00 − sin(θ) cos(θ) 00 0 0 1

Rotation Around y–Axis

R( j,θ,Origin) =

cos(θ) 0 sin(θ) 00 1 0 0

−sin(θ) 0 cos(θ) 00 0 0 1

Mirror Through the xy–Plane

S = xy–Plane•

n = k = 0 0 1( )•

Q = Origin = 0 0 0( )

Matrices

I =

1 0 00 1 00 0 1

k ⊗ k =

0 0 00 0 00 0 1

Mirror Through the xy–Plane (continued)

4 × 4 Mirror Image Matrix

M(k,Origin) =I − 2k ⊗ k 0

2(Origin• k)k 1

I − 2k ⊗ k =

1 0 00 1 00 0 1

0 0 00 0 00 0 2

=

1 0 00 1 00 0 −1

M(k,Origin) =

1 0 0 00 1 0 00 0 −1 00 0 0 1

Mirror Through the xz,yz–Planes (Exercise)

Mirror in yz–Plane

R(i,Origin) =

−1 0 0 00 1 0 00 0 1 00 0 0 1

Mirror in xz–Plane

R( j,Origin) =

1 0 0 00 −1 0 00 0 1 00 0 0 1

4 × 4 Scaling Matrix

S(c,Origin) =cI 0

(1− c)Origin 1

=

c 0 0 00 c 0 00 0 c 00 0 0 1

Non–Uniform Scaling Along Coordinate Axes

Scaling Along x–Axis

S(Origin,c,i ) =I − (1− c)(i⊗ i) 0

(1− c)(Origin•i)i 1

=

c 0 0 00 1 0 00 0 1 00 0 0 1

Scaling Along y–Axis

S(Origin,c, j) =I − (1− c)( j⊗ j) 0

(1− c)(Origin• j) j 1

=

1 0 0 00 c 0 00 0 1 00 0 0 1

Scaling Along z–Axis

S(Origin,c,k) =I − (1− c)(k ⊗ k) 0

(1− c)(Origin• k)k 1

=

1 0 0 00 1 0 00 0 c 00 0 0 1

Orthogonal Projection into Coordinate Planes

Projection into xy-Plane

OProj(k,Origin) =I − k ⊗ k 0

(Origin• k)k 1

=

1 0 0 00 1 0 00 0 0 00 0 0 1

Projection into yz-Plane

OProj(i,Origin) =I − i ⊗ i 0

(Origin•i)i 1

=

0 0 0 00 1 0 00 0 1 00 0 0 1

Projection into xz-Plane

OProj( j,Origin) =I − j ⊗ j 0

(Origin• j) j 1

=

1 0 0 00 0 0 00 0 1 00 0 0 1

Parallel Projection into xy–Plane

xy–Plane•

n = k = 0 0 1( )•

Q = Origin = 0 0 0( )

Projection Direction•

w = w1 w2 w3( )

Computations•

w•n = w•k = w3

n⊗w = k ⊗w =

0 0 00 0 0

w1 w2 w3

Parallel Projection into xy–Plane (continued)

4 × 4 Projection Matrix

Pproj(k,Origin,w) =I − (k ⊗w) / (k •w) 0

(Origin•k ) / (k •w)( )w 1

I − (k ⊗w) / (k •w) =

1 0 00 1 00 0 1

− (1/ w3)

0 0 00 0 0w1 w2 w3

=

1 0 00 1 0

w1 /w3 w2 / w3 0

Pproj(k,Origin,w) =

1 0 0 00 1 0 0

w1 /w3 w2 /w3 0 00 0 0 1

Perspective Projection into xy–Plane from Below

xy–Plane•

n = k = 0 0 1( )•

Q = Origin = 0 0 0( )

Eye Point•

R = 0 0 −1( )

Computations•

Q•n = Origin• k = 0•

R•n = R•k = −1

n⊗ R = k ⊗R =

0 0 00 0 00 0 −1

Perspective Projection into xy–Plane from Below (continued)

4 × 4 Perspective Matrix

Persp(k,Origin,R) =(R−Origin)•k( )I − (k ⊗R) −t k

Origin•k( )R R•k

(R −Origin)• k( )I − (k ⊗ R) = −

1 0 00 1 00 0 1

0 0 00 0 00 0 −1

=

−1 0 00 −1 00 0 0

Persp(k,Origin,R) =

−1 0 0 00 −1 0 00 0 0 −10 0 0 −1

Perspective Projection into xy–Plane from Below (continued)

4 × 4 Perspective Matrix

Persp(k,Origin,R) =

−1 0 0 00 −1 0 00 0 0 −10 0 0 −1

Coordinate Computation

(x,y,z,1)∗

−1 0 0 00 −1 0 00 0 0 −10 0 0 −1

= (−x,−y,0,−z −1)

xnew =x

z +1 ynew =

yz+1

znew = 0

Affine Transformations

(xnew ,ynew ,znew ,1) = (xold ,yold ,zold ,1)∗

a e i 0b f j 0c g k 0d h l 1

xnew = axold + byold + czold + d

ynew = exold + fyold + gzold + h

znew = ixold + jyold + kzold + l

Projective Transformations

(xnew ,ynew ,znew ,1) = (xold ,yold ,zold ,1)∗

a e i mb f j nc g k pd h l q

xnew =axold +byold +czold + dmxold +nyold + pzold +q

ynew =exold + fyold + gzold + hmxold + nyold + pzold + q

znew = ixold + jyold + kzold + lmxold +nyold + pzold +q

Summary

Linear Transformations --

3× 3 Matrices

xnew = axold + byold + czoldynew = exold + fyold + gzoldznew = ixold + jyold + kzold

Affine Transformations --

4 × 4 Matrices

xnew = axold + byold + czold + dynew = exold + fyold + gzold + hznew = ixold + jyold + kzold + l

→ 4 th Row = Translation

Projective Transformations --

4 × 4 Matrices

xnew =axold +byold +czold + dmxold +nyold + pzold +q

ynew =exold + fyold + gzold + hmxold + nyold + pzold + q

znew = ixold + jyold + kzold + lmxold +nyold + pzold +q€

→ 4 th Column = Projection