Transformations - PowerPoint PPT Presentation

1 / 78
About This Presentation
Title:

Transformations

Description:

Linear algebra review tomorrow Wednesday at 7:30 in 32-D507 ... Pinhole Camera. 6.837 Fall 06 Durand. 6. Synthetic Camera. Viewing. Modeling ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 79
Provided by: barbara233
Category:

less

Transcript and Presenter's Notes

Title: Transformations


1
Transformations Homogeneous Coordinates
6.837 Introduction to Computer Graphics Fredo
Durand, MIT EECS
2
Administrivia
  • Linear algebra review tomorrow Wednesday at 730
    in 32-D507
  • You should be well started with assignment 1
    (due next week)

3
Eugene has setup a remote Athena
  • Hi all, I've recently set up an Athena Linux
    machine for remote logins (so you folks can work
    at home).  Before I continue though, let me just
    say that this is not an officially supported
    solution (which is why I'm sending it to
    6837-discuss rather than 6837-students, because
    6837-students is reserved for official
    announcements). This means Use the machine
    at your own risk.  If you're working on it, and
    it happens to crash two hours before the
    assignment, it's not an excuse for lateness.
    The official course staff answer to any setup
    questions will be we encourage you to work in a
    cluster, since we don't have the resources to
    offer technical support on personal machines.
    With that stated, the machine is (drumroll)
    eraser.csail.mit.edu I've only enabled login
    access to all people that currently have turnin
    directories.  And here are basic usage
    instructions LINUX  If you have a Linux
    machine at home, you should be able to ssh -X
    into the machine and run applications remotely. 
    I've tried this on several Linux machines, and it
    only worked on some of them, and that's all I can
    say about that. WINDOWS  MIT has XWin32
    available from their software distrubtion page
    (http//web.mit.edu/software/).  You can use this
    to connect to eraser remotely and run
    applications.  Note that you need to disable
    "Advanced Window Caching" in the configuration
    (otherwise, OpenGL windows will pop up blank).
    MAC  In theory, OS X allows you to run X
    applications remotely, but I've never tried it. 
    See the following http//www.apple.com/downloads/
    macosx/apple/x11formacosx.html Good luck.
    Eugene

4
Assignment 0
  • Fixed size array
  • Kind of dirty, but OK for asst0
  • But make sure they are big enough!!!!
  • Now you should use vectors (variable-size array)
  • putting glBegin(GL_TRIANGLES)/glEnd() inside of
    the loop instead of outside is not optimal
    slower drawing...

5
Pinhole Camera
6
Synthetic Camera
7
Modeling Problem
  • Write an OpenGL procedure that draws a 2D
    rectangle with one corner at (lox, loy) and
    another at (hix, hiy).

8
Solution
drawBox(lox, loy, hix, hiy) glBegin(GL_QUADS)
glVertex2f(lox, loy) glVertex2f(hix,
loy) glVertex2f(hix, hiy) glVertex2f(lox,
hiy) glEnd()
9
Another Solution
  • Assume drawUnitBox() procedure draws a unit box
  • This is a solution you should use in almost all
    graphics application speed, modularity,
    flexibility,

drawBox(lox, loy, hix, hiy) glTranslate(lox,
loy) glScale(hix-lox, hiy-loy) drawUnitBox()

10
Another Example
  • Write an OpenGL procedure that draws an ellipse
    assuming drawUnitCircle() draws a unit-circle
    centered at the origin.

drawEllipse(cx, cy, rx, ry) glTranslate(cx,
cy) glScale(rx, ry) drawUnitCircle()
11
Geometry Pipeline Modeling
12
Geometry Pipeline Viewing
13
OpenGL Example Modeling
// Current matrix affects objects
positions glMatrixMode( GL_MODELVIEW ) //
Initialize to the identity glLoadIdentity()
// Position the camera at 0,0,5,
looking at // 0,0,0, with 0,1,0 as the up
direction. gluLookAt(0.0, 0.0, 5.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0) //
Rotate by -20 degrees about 0,1,0 glRotated(-20.
0, 0.0, 1.0, 0.0) // Draw a
teapot. glutSolidTeapot(1.0)
14
OpenGL Example Viewing
// Set up a perspective view, // with square
aspect ratio glMatrixMode(GL_PROJECTION) glLoadId
entity() // perspective camera // field of
view, aspect ratio, gluPerspective(50.0, 1.0,
1.0, 100.0)
15
Questions?
16
Outline
  • Intro to Transformations
  • Classes of Transformations
  • Representing Transformations
  • Combining Transformations
  • Fun Iterated Function Systems
  • Hardcore transforming normals

17
What is a Transformation?
  • A function that maps points x to points x'
  • Applications animation, deformation, viewing,
    projection, real-time shadows,

From Sederberg and Parry, Siggraph 1986
18
Simple Transformations
  • Can be combined
  • Are these operations invertible?

Yes, except scale 0
19
Outline
  • Intro to Transformations
  • Classes of Transformations
  • Representing Transformations
  • Combining Transformations
  • Transformations in Modeling

20
Rigid-Body / Euclidean Transforms
  • Preserves distances
  • Preserves angles

Rigid / Euclidean
Identity
Translation
Rotation
21
Similitudes / Similarity Transforms
  • Preserves angles

Similitudes
Rigid / Euclidean
Identity
Translation
Isotropic Scaling
Rotation
22
Linear Transformations
Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Translation
Isotropic Scaling
Reflection
Rotation
Shear
23
Linear Transformations
?
  • L(p q) L(p) L(q)
  • L(ap) a L(p)

Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Translation
Isotropic Scaling
Reflection
Rotation
Shear
Translation is not linear because apt ? a(pt)
24
Affine Transformations
  • preserves parallel lines

Affine
Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Translation
Isotropic Scaling
Reflection
Rotation
Shear
25
Projective Transformations
  • preserves lines

Projective
Affine
Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Translation
Isotropic Scaling
Reflection
Rotation
Shear
Perspective
26
Physical 3D perspective
  • In Rome
  • Walls recede
  • Makes it look longer

Side view
Borromini
27
Groups
  • Properties of a group (element, operation)
  • There exists a neutral element
  • There exists an inverse for each member
  • The elements are "closed under composition"
  • The composition operation is associative
  • Example integers under addition
  • 0 is the neutral element
  • -x is the inverse of x
  • xy is an integer
  • (xy)zx(yz)

28
Groups and Transformations
  • Properties of a group
  • There exists an identity mapping
  • There exists an inverse mapping for each function
  • The functions are "closed under composition"
  • The composition operation is associative
  • These properties might seem trivial at first
    glance, but they are actually very important,
    because when these conditions are shown for any
    class of functions and their two-argument
    composition operation, then they form an
    algebraic group. One of the consequences is that
    any series of translations can be composed to a
    single translation. Another consequence is that
    the inverse is unique.

29
Questions?
30
Visual tribute to Darcy Thompson
  • The first biomathematician
  • Transformation evolution
  • http//www-gap.dcs.stand.ac.uk/history/Miscellane
    ous/darcy.html

31
Outline
  • Intro to Transformations
  • Classes of Transformations
  • Representing Transformations
  • Combining Transformations
  • Fun Iterated Function Systems
  • Hardcore transforming normals

32
How are Transforms Represented?
x' ax by c y' dx ey f
c f
x y
x' y'
a b d e


p' M p t
33
Translation in homogenous coordinates
x' ax by c y' dx ey f
Affine formulation
Homogeneous formulation
c f 1
x y 1
x' y 1
a b d e 0 0

c f
x y
x' y'
a b d e


p' M p t
p' M p
34
Homogeneous Coordinates
  • Add an extra dimension
  • in 2D, we use 3 x 3 matrices
  • In 3D, we use 4 x 4 matrices
  • Each point has an extra value, w

x y z w
a e i m
b f j n
c g k o
d h l p
x' y' z' w'

p' M p
35
Homogeneous Coordinates
  • Most of the time w 1, and we can ignore it
  • If we multiply a homogeneous coordinate by an
    affine matrix, w is unchanged

x y z 1
a e i 0
b f j 0
c g k 0
d h l 1
x' y' z' 1

36
Homogeneous Visualization
  • Divide by w to normalize (homogenize)
  • W 0?
  • Point at infinity (direction)

(0, 0, 1) (0, 0, 2)
w 1
(7, 1, 1) (14, 2, 2)
w 2
(4, 5, 1) (8, 10, 2)
37
Questions?
38
Translate (tx, ty, tz)
Translate(c,0,0)
y
  • Why bother with the extra dimension?Because now
    translations can be encoded in the matrix!

p'
p
x
c
x y z 1
1 0 0 0
0 1 0 0
0 0 1 0
tx ty tz 1
x' y' z' 1
x' y' z'

39
Scale (sx, sy, sz)
Scale(s,s,s)
p'
y
  • Isotropic (uniform) scaling sx sy sz

p
q'
q
x
x y z 1
sx 0 0 0
0 sy 0 0
0 0 sz 0
0 0 0 1
x' y' z' 1

40
Rotation
ZRotate(?)
y
p'
  • About z axis

?
p
x
z
x y z 1
cos ? sin ? 0 0
-sin ? cos ? 0 0
0 0 1 0
0 0 0 1
x' y' z' 1

41
Rotation
Rotate(k, ?)
y
?
  • About (kx, ky, kz), a unit vector on an
    arbitrary axis(Rodrigues Formula)

k
x
z
kxkx(1-c)c kykx(1-c)kzs kzkx(1-c)-kys 0
kzkx(1-c)-kzs kzkx(1-c)c kzkx(1-c)-kxs 0
kxkz(1-c)kys kykz(1-c)-kxs kzkz(1-c)c 0
x' y' z' 1
x y z 1
0 0 0 1

where c cos ? s sin ?
42
Questions?
43
Outline
  • Intro to Transformations
  • Classes of Transformations
  • Representing Transformations
  • Combining Transformations
  • Fun Iterated Function Systems
  • Hardcore transforming normals

44
How are transforms combined?
Scale then Translate
(5,3)
(2,2)
Scale(2,2)
Translate(3,1)
(1,1)
(3,1)
(0,0)
(0,0)
Use matrix multiplication p' T ( S p )
TS p
0 2
0 1
0 2
2 0
0 0
1 0
3 1
2 0
3 1
TS

Caution matrix multiplication is NOT commutative!
45
Non-commutative Composition
Scale then Translate p' T ( S p ) TS p
(5,3)
(2,2)
Scale(2,2)
Translate(3,1)
(1,1)
(3,1)
(0,0)
(0,0)
Translate then Scale p' S ( T p ) ST p
(8,4)
(4,2)
Translate(3,1)
Scale(2,2)
(6,2)
(1,1)
(3,1)
(0,0)
46
Non-commutative Composition
Scale then Translate p' T ( S p ) TS p
0 2 0
0 1 0
0 2 0
2 0 0
0 0 1
1 0 0
3 1 1
2 0 0
3 1 1
TS

Translate then Scale p' S ( T p ) ST p
0 2
0 1
0 2
2 0
0 0
1 0
3 1
2 0
6 2
ST

47
Questions?
48
Outline
  • Intro to Transformations
  • Classes of Transformations
  • Representing Transformations
  • Combining Transformations
  • Fun Iterated Function Systems
  • Hardcore transforming normals

49
Fun Iterated Function Systems (IFS)
  • Example of fractal
  • Capture self similarity using set of linear
    transforms fi

50
Fun Iterated Function Systems (IFS)
  • Contraction (reduce distances)
  • An attractor is a fixed point

51
Example Sierpinski Triangle
  • Described by a set of n affine transformations
  • In this case, n 3
  • translate scale by 0.5

52
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
53
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
54
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
55
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
56
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
57
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
58
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
59
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
60
Example Sierpinski Triangle
for lots of random input points (x0, y0) for
j0 to num_iters randomly pick transformation
i (xk1, yk1) fi (xk, yk) display (xk, yk)
Increasing the number of iterations
61
Another IFS The Dragon
62
Application Fractal Compression
  • Exploit the self-similarity in an image

Compressed using Fractal Photo Lab
63
Questions?
64
Outline
  • Intro to Transformations
  • Classes of Transformations
  • Representing Transformations
  • Combining Transformations
  • Fun Iterated Function Systems
  • Hardcore transforming normals

65
Normal
  • Surface Normal unit vector that is locally
    perpendicular to the surface

66
Why is the Normal important?
  • It's used for shading makes things look 3D!

object color only
Diffuse Shading
67
Visualization of Surface Normal
  • x Red y Green z Blue

68
How do we transform normals?
nWS
nOS
World Space
Object Space
69
Transform Normal like Object?
  • translation?
  • rotation?
  • isotropic scale?
  • scale?
  • reflection?
  • shear?
  • perspective?

70
Transform Normal like Object?
  • translation?
  • rotation?
  • isotropic scale?
  • scale?
  • reflection?
  • shear?
  • perspective?

71
What class of transforms?
Projective
Affine
Similitudes
Similitudes
Linear
Rigid / Euclidean
Scaling
Identity
Identity
Translation
Isotropic Scaling
Reflection
Translation
Isotropic Scaling
Reflection
Rotation
Rotation
Shear
Perspective
a.k.a. Orthogonal Transforms
72
Transformation for shear and scale
Incorrect Normal Transformation
Correct Normal Transformation
73
More Normal Visualizations
Incorrect Normal Transformation
Correct Normal Transformation
74
So how do we do it right?
  • Think about transforming the tangent plane to
    the normal, not the normal vector

nOS
nWS
vWS
vOS
Original
Incorrect
Correct
Pick any vector vOS in the tangent plane, how is
it transformed by matrix M?
vWS M vOS
75
Transform tangent vector v
v is perpendicular to normal n
nOST vOS 0
Dot product
nOS
nOST (M-1 M) vOS 0
(nOST M-1) (M vOS) 0
vOS
(nOST M-1) vWS 0
vWS is perpendicular to normal nWS
nWST nOST (M-1)
nWS
nWS (M-1)T nOS
vWS
nWST vWS 0
76
Comment
  • So the correct way to transform normals is
  • But why did nWS M nOS work for similitudes?
  • Because for similitude / similarity transforms,
  • (M-1)T l M
  • e.g. for orthonormal basis

nWS (M-1)T nOS
Sometimes noted M-T
M
M-1
77
Buzzword
  • Which you dont need to remember
  • Covariant transformed by the matrix
  • e.g. tangent
  • Contravariant transformed by the transpose
    inverse
  • e.g. the normal

78
Next Transformations in Modeling
  • Robot Arm
  • Camera Location
  • gluLookAt(eye, , center, , up, )
Write a Comment
User Comments (0)
About PowerShow.com