geometric transforms - fabio...

Post on 12-Jul-2020

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

geometric transforms

1

linear algebra review

2

matrices

matrix and vector notation

use column for vectors

M = [ ] = [ ]m11

m21

m12

m22mij

v = [ ] =v1

v2[ ]v1 v2

T

3

matrix operations

addition

scalar multiplication

T = M + N

[ ] = [ ]tij +mij nij

T = aM

[ ] = [ ]tij amij

4

matrix operations

matrix-matrix multiplication

row-column multiplication

not commutative

associative

T = MN = [ ] = [ ]tij ∑k

miknkj

=⎡⎣⎢⎢

t11

t21

t12

t22

⎤⎦⎥⎥

⎡⎣⎢⎢

m11

m21

m12

m22

⎤⎦⎥⎥⎡⎣⎢⎢

n11

n21

n12

n22

⎤⎦⎥⎥

5

matrix operations

matrix-vector multiplication

row-column multiplication

u = Mv

=⎡⎣⎢⎢

u1

u2

⎤⎦⎥⎥

⎡⎣⎢⎢

m11

m21

m12

m22

⎤⎦⎥⎥⎡⎣⎢⎢

v1

v2

⎤⎦⎥⎥

6

matrix operations

transpose: flip along diagonal

inverse (not computed explicitly in this course)

T = MT

[ ] = [ ]tij tji

T = M−1

MT = M = M = IM−1 M−1

7

special matrices

identity: invariant for multiplication

I = [ ] = {iij10

i = ji ¡ j

I = [ ]10

01

:M : M = MI = IM

8

special matrices

zero: invariant for addition

O = [ ] = 0iij

I = [ ]00

00

:M : M = M + O = O + M

9

matrix operation properties

linearity of multiplication and addition

associativity of multiplication

a(A + B) = aA + aB

M(aA + bB) = aMA + bMB

A(BC) = (AB)C

10

matrix operation properties

transpose and inverse of multiplication

(AB =)T BT AT

(AB =)−1 B−1A−1

11

2d transformation

12

geometric transformations

functions that maps points to points

different transformations have restrictions on the form of

p Ü = X(p)p′

X

13

translation

(p) = p + tTt

(p) = (p) = p − tT −1t T−t

14

linear transformations

fundamental property:

can be represented in matrix form:

properties:

maps origin to origin

maps lines to lines

parellel lines remain parallel

length ratios are preserved

closed under composition

X(ap + bq) = aX(p) + bX(q)X(p) = Mp

15

uniform scale

p = [ ][ ] = [ ]Sss0

0s

pxpy

spxspy

=S−1s S1/s

16

non-uniform scale

p = [ ][ ] = [ ]Sssx

00sy

pxpy

sxpxsypy

=S−1s S1/s

17

rotation

p = [ ][ ] = [ ]R?cos ?sin ?

− sin ?cos ?

pxpy

cos ? − sin ?px py

sin ? + cos ?px py

=R−1? R−?

18

shear

S p = [ ][ ] = [ ]hs1sy

sx

1pxpy

+px sxpy

+sypx py

19

reflection

R p = [ ][ ] = [ ] R p = )lx−10

01

pxpy

−pxpy

ly

R p = [ ][ ] = [ ]lo−10

0−1

pxpy

−px−py

20

affine transforms

combine translation with linear transformation

rigid body transformation are a subset of this

properties

does not map origin to origin

maps lines to lines

parallel lines remain parallel

length ratios are preserved

closed under composition

(p) = Mp + tXM,t

21

transforming points and vectors

points and vectors are different entities

vectors: encode direction and length (difference of points)

points: encode position (origin plus a vector)

points: transform as reported above

vectors: transform like points, but no translation is applied

directions (normalized vectors): normalize after transform

X(p) = Mp + t

X(v) = Mv

X( ) = M /| M |d̂ d̂ d̂

22

transforming points and vectors

proof that vectors transform as such

vX(p)X(v)

= p − q= Mp + t= X(p) − X(q) == (Mp + t) − (Mq + t) == M(p − q) == Mv

23

homogeneous coordinates

represent points/vectors with an additional coordinate

set it to 1 for points (or multiply all per arbitrary )

set it to 0 for vectors

ww

p = ¢⎡

⎣⎢⎢

pxpy

1

⎦⎥⎥

⎣⎢⎢

wpxwpy

w

⎦⎥⎥

v =⎡

⎣⎢⎢

vx

vy

0

⎦⎥⎥

24

homogeneous coordinates

translation: represent as 3x3 matrix

shorthand notation for points and vectors

p = =Tt

⎣⎢⎢

100

010

tx

ty

1

⎦⎥⎥⎡

⎣⎢⎢

pxpy

1

⎦⎥⎥

⎣⎢⎢

+px tx

+py ty

1

⎦⎥⎥

p = [ ][ ] = [ ]TtI0

t1

p1

p + t1

v = [ ][ ] = [ ]TtI0

t1

v0

v0 25

homogeneous coordinates

linear transform: 3x3 matrix by adding one row,column

shorthand notation for points and vectors

Mp = =⎡

⎣⎢⎢

m11

m21

0

m12

m22

0

001

⎦⎥⎥⎡

⎣⎢⎢

pxpy

1

⎦⎥⎥

⎣⎢⎢

+m11px m12py

+m21px m22py

1

⎦⎥⎥

Mp = [ ][ ] = [ ]M0

01

p1

Mp1

Mv = [ ][ ] = [ ]M0

01

v0

Mv0 26

affine transformations

combine linear and translation in one matrix

Xp = [ ][ ] = Mp + tM0

t1

p1

Xv = [ ][ ] = MvM0

t1

v0

27

combining transforms

apply one transformation after the another

express by function composition

for affine transformations, compute by matrix multiplication

= ( (p)) = ( Q (p))p′ X2 X1 X2 X1

( Q (p)) = ( (p)) = ( )p = ( )pX2 X1 X2 X1 M2 M1 M2M1

28

combining transforms

translation

linear transformations

[ ][ ] = [ ]I0

t2

1I0

t1

1I0

+t1 t2

1

[ ][ ] = [ ]M2

001

M1

001

M2 M1

001

29

combining transforms

affine transformations

[ ][ ] = [ ]M2

0t2

1M1

0t1

1M2M1

0+M2 t1 t2

1

30

composition is not commutative

original rotation translation

original transation rotation 31

complex transformations

represent as combination of simpler ones

intuitive geometric interpretation

rotation around arbitrary axis at of angle

translate axis center to origin

rotate (about origin)

translate back

a ?

=Ra,? TaR?T−a

32

complex transformations

33

complex transformations

34

transforms and coordinate systems

change of coordinate system can be written as affine matrix

for , we have

that in matrix form becomes

Ü ff ′ p = + + +f ′O p′

xf ′x p′

xf ′y p′

xf ′z

p = [ ][ ] = [ ][ ]M0

t1

p′

1f ′

x

0

f ′y

0

f ′z

0

f ′o

1p′

1

35

transforms and coordinate systems

for , we invert the previous equation

since is orthonormal,

f Ü f ′

= [ ][ ]p′ M−1

0tM −1

1p1

M =M −1 MT

=p′

⎢⎢⎢⎢

x′T

y′T

z′T

0

˝ tx′

˝ ty′

˝ tz′

1

⎥⎥⎥⎥

⎢⎢⎢⎢

pxpy

pz

1

⎥⎥⎥⎥

36

3d transformations

37

3d transformations

adopt homogeneous formulation in 3d

point have 4 coordinates

use 4x4 matrices for transformations

most concepts generalize very easily

rotation much more complex

38

translation

=Tt

⎢⎢⎢⎢

1000

0100

0010

txty

tz

1

⎥⎥⎥⎥

39

scale

=Ss

⎢⎢⎢⎢

sx

000

0sy

00

00sz

0

0001

⎥⎥⎥⎥

40

rotation around z

=Rz?

⎢⎢⎢

cos ?sin ?

00

−sin ?cos ?

00

0010

0001

⎥⎥⎥

41

rotation around y

=Ry?

⎢⎢⎢

cos ?0

−sin ?0

0100

sin ?0

cos ?0

0001

⎥⎥⎥

42

rotation around x

=Rx?

⎢⎢⎢

1000

0cos ?sin ?

0

0−sin ?cos ?

0

0001

⎥⎥⎥

43

rotation around arbitrary axis

in 2D, rotation are around a point:

change coordinate frame (translation)

rotation around the origin

change coordinate frame back

simple geometric construction

in 3D, rotation are around an axis:

change coordinate frame (align with axis )

rotation around

change coordinate frame back

complex geometric construction

=Ra,? TaR?T−a

=Ra,? F−1aR?Fa

z az

44

representing rotations

Euler angles: 3 rotations around major axis

remember to choose order

simple but has quirks when combining rotations

will use this for simplicity

axis and angle

combinations of rotations can be represented this way

with more formalism become elegant and consistent

quaternions

45

transforming normals

points and vectors works

tangents, i.e. differences of points, work too

normals works differently

defined as orthogonal to the transformed surface

i.e. orthogonal to all tangents

46

transforming normals

by definition:

after tranform:

for all we have:

which gives:

normals are transformed by the inverse transpose

t ˝ n = n = 0tT

(Mt (Xn) = 0)T

t Xn = 0tT M T

( n = 0tT M T MT )−1

47

transformation hierarchies

48

transformation hierarchies

often need to transform an object wrt another

e.g. the computer on the table

when the table moves, the computer moves

naturally build a hierarchy of transformation

to transform the table, apply its transform

to transform the computer, apply the table and the

computer transform

49

transformation hierarchies

represented as a tree data structure

transformation nodes

object nodes / leaves

walk the tree when drawing

very convenient representation for objects

all objects can be defined in their simplest form

e.g. every sphere can be represented by a transformation

applied to the unit sphere

50

transformation hierarchies

51

implementing transform hierarchies

transformation function for each node

get the parent matrix

multiply the parent and current matrices

pass the combined matrix when calling children

stack of transforms

push/pop when walking down/up

used by graphics libraries (OpenGL)

more flexible

generalized mechanism for all attributes

52

raytracing and transformations

transform the object

simple for triangles, since they transforms to triangles

but most objects require complex intersection tests

spheres do not transforms to spheres, but ellipsoids

transform the ray

much more elegant

works on any surface

allow for much simpler intersection tests

only worry about unit sphere, all others are transformed

53

raytracing and transformations

transforming rays

transform origin/direction as point/vector

note that direction is not normalized now

i.e. ray parameter is not the distance

intersect a transformed object

transform the ray by matrix inverse

intersect surface

transform hit point and normal by matrix

works like changes in coodinate system

54

top related