     3D Transformations - II 3D Transformations - II Computer Graphics COMP 770 (236) Spring 2007 Instructor:

• View
2

0

Embed Size (px)

Text of 3D Transformations - II 3D Transformations - II Computer Graphics COMP 770 (236) Spring 2007...

• 1/29/07 1

3D Transformations - II

Computer Graphics COMP 770 (236) Spring 2007

Instructor: Brandon Lloyd

• 1/29/07 2

From last time… ■ Mathematical foundations

° scalar fields, vector spaces, affine spaces ° linear transformations, matrices

■ Entities ° vectors, points, frames

■ Changing frames v. transforming coordinates

• 1/29/07 3

Outline ■ Where are we going?

° Sneak peek at the rendering pipeline

■ Vector algebra ° Dot product, cross product, tensor product

■ Modeling transformations ° Translation, rotation, scale

■ Viewing transformation ■ Projections

° Orthographic, perspective

• 1/29/07 4

The classic rendering pipeline ■ Seldom depicted the same way ■ Seldom implemented the same

way ■ Object primitives defined by

vertices fed in at the top. Pixels come out in the display at the bottom

■ Commonly have multiple primitives in various stages of rendering

• 1/29/07 5

Modeling transformations ■ 3-D models defined in model space with their

own modeling frames:

■ Modeling transformations orient models within a common coordinate frame called world space:

■ All objects, light sources, cameras live in world space

■ Trivial rejection eliminates objects that cannot possibly be seen (an optimization)

t n

t 2

t 1 m,...,m,m

tw

• 1/29/07 6

Illumination ■ Computes illumination for potentially visible

objects ■ Light sources defined relative to some frame:

■ Final rendered color is determined by: ° object’s orientation ° object’s material properties ° light sources

t n

t 2

t 1 l,...,l,l

• 1/29/07 7

Viewing transformation ■ Maps points from world space to eye space:

■ Viewing position is transformed to the origin ■ Viewing direction is oriented along some axis

Vtt we =

• 1/29/07 8

Clipping and projection ■ Volume of points within the view called a view

frustum ■ Map view frustum to the unit cube ■ Clip objects against the view volume, thereby

eliminating geometry not visible in the image ■ Objects are projected

into two-dimensions ■ Transformation from

eye space to normalized device coordinates

• 1/29/07 9

Rasterization and display ■ Transform normalized device coordinates to

scree space ■ Rasterization converts objects to pixels

■ Almost every step in the rendering pipeline involves a change of coordinate systems!

■ Transformations are central to understanding three-dimensional computer graphics.

• 1/29/07 10

multiplications by a scalar ■ Three kinds of vector multiplication

° Dot product ( ⋅ ) - returns a scalar ° Cross product ( × ) - returns a vector ° Tensor product ( ⊗ ) - returns a matrix

• 1/29/07 11

Dot product ( ⋅ )

■ Returns a scalar s ■ Geometric interpretation of s:

° the length of projected onto or vice versa. ° ° distance of from the origin

in direction

x x

y yT T x y z x y z

z z

b b b b

a b a b a a a 0 s a b a b a a a 0 s b b 0 1

⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥⋅ ≡ = = ⋅ ≡ = =⎡ ⎤ ⎡ ⎤⎣ ⎦ ⎣ ⎦⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦

b â

b a

a b cosθ

θ

a

b

a b a⋅

• 1/29/07 12

Cross product ( × )

■ Returns a vector that is perpendicular to both and , oriented according to the right-hand rule

■ The matrix form is called skew-symmetric matrix of denoted A×

■ Note: cross products produce vectors for both vector and point inputs.

z y x

z x y

y x z

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

0 a a 0 b a 0 a 0 b a c 0

a b c a a 0 0 b b c 0 0 0 0 0 0

c [a b a b a b a b a b a b ]

−⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥− ⋅ = ⎢ ⎥ ⎢ ⎥× ≡ = − ⋅ =⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦ = − − −

a

a bc

• 1/29/07 13

Cross product ( × ) ■ A mnemonic device for remembering the cross-product

x y z

x y z

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

i j k a b det a a a

b b b

(a b a b )i (a b a b ) j (a b a b )k

⎡ ⎤ ⎢ ⎥× ≡ ⎢ ⎥ ⎢ ⎥⎣ ⎦

= − + − + −

i [1 0 0]

j [0 1 0]

k [0 0 1]

=

=

=

• 1/29/07 14

Tensor product ( ⊗ ) x x x x y x z

y y x y y y zt x y z

z z x z y z z

x x y y z z x

x x y y z z y

x x y y z z z

a ab ab ab 0 a a b a b a b 0

a b ab b b b 0 a a b a b a b 0 0 0 0 0 0

(b c b c b c )a (a b)c (b c b c b c )a a(b c)

(b c b c b c )a

⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥⊗ ≡ = =⎡ ⎤⎣ ⎦⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦ + +⎡ ⎤

⎢ ⎥⊗ = + + = ⋅⎢ ⎥ ⎢ ⎥+ +⎣ ⎦

■ Creates a matrix that when applied to a vector returns scaled by the projection of onto c

a b

c

• 1/29/07 15

Tensor product ( ⊗ )

x x x y x z

y x y y y z

z x z y z z

a a a a a a 0 a a a a a a 0

a a a a a a a a 0 0 0 0 0

⎡ ⎤ ⎢ ⎥ ⎢ ⎥= ⊗ = ⎢ ⎥ ⎢ ⎥ ⎣ ⎦

A

■ Useful when ■ The matrix is called the

symmetric matrix of . We shall denote this A⊗

b a= a

c

c⊗A

a a⊗ a

• 1/29/07 16

Modeling transformations ■ Vast majority of transformations are modeling

transformations ■ Generally fall into one of two classes:

° Transforms that move parts within the model

° Transformations that relate a local model’s frame to the scene’s world frame:

■ Usually, only Euclidean and Similitude transformations are needed

t t t 1 1m (m ) w⇒ =c M c c

t t t 1 1 1m m ( ) m ′⇒ =c Mc c

• 1/29/07 17

Computing modeling transformations

■ What is the transformation M from one frame to another?

Ax

Ay

Ao Bx

By

Bo t B B B Bm (x , y ,o )=

M

t A A A Am (x , y ,o )=

B B B

t t B A

B B B A A A x y o

m m [x y o ] [x y o ][ ]

= =

M c c c

B A B A B A A

B A B A B A A

x x y x (o o ) x x y y y (o o ) y

0 0 1

⋅ ⋅ − ⋅⎡ ⎤ ⎢ ⎥= ⋅ ⋅ − ⋅⎢ ⎥ ⎢ ⎥⎣ ⎦

M

• 1/29/07 18

Computing modeling transformations

■ M is the new coordinate system in terms of the old one.

■ To transform points we use M-1, which is the old coordinate system expressed in terms of new one

■ What if ?

t t 1 t 1 t A A B A B A B Bp m (m ) m ( ) m

− −≡ = = =c M c M c c

B B B

t t t B A A x y om m m [ ]= =M c c c

t t Bm w=

A A A

t t 1 t A A A x y o Am w w [ ]

−= =c M c c c c c

1 A A A[x y o ]

− =M

• 1/29/07 19

Computing modeling transformations

■ What if ?

■ In other words, the transformation is simply the modelling frame itself!

t t Bm w=

A A A

t t A A A A

t t 1 t A A A A A

t t t A x y o

1 A A A A

(m ) w

m (w ) w ( )

m w w [ ]

[x y o ]

=

= =

= =

= =

M c c c M c Mc

M c c c

M M

• 1/29/07 20

Translations ■ Translate points by adding offsets to their coordinates

■ The effect of translation:

x t t t

y t t t

z

1 0 0 t 0 1 0 tm m ( ) m

where 0 0 1 tm (m ) w 0 0 0 1

⎡ ⎤ ⎢ ⎥′⇒ = ⎢ ⎥=

⇒ = ⎢ ⎥ ⎢ ⎥ ⎣ ⎦

c Tc c T

c T c c

• 1/29/07 21

3D rotations ■ More complicated than 2D rotations

° Only one choice of rotation axis that leaves points in the plane in 2D

■ Several approaches: ° Compose three canonical rotations about the axes

° error prone ° ambiguous

° Axis-angle ° Quaternions – magic

• 1/29/07 22

Geometry of a rotation Natural basis for rotation of a vector about a specified

axis: ° - rotation axis (normalized) ° - vector perpendicular to ° - perpendicular component of relative to

â x×

x

x⊥

x⊥

â x×

x â

• 1/29/07 23

Geometry of a rotation â

x

x⊥ â x×

x′ x

â x

ˆb a x= × x x

x⊥′x⊥ θ0 x⊥

x cos x sin bθ θ⊥ ⊥′ = + x 0 x x⊥′ ′= + +

ˆ ˆ ˆx 0 cos x (1 cos )(a(a x)) sin (a x)θ θ θ′ = + + − ⋅ + ×

tdiag(0) cos diag([1 1 1 0] ) (1 cos ) sin

θ θ θ⊗ ×

= +

+ − +

M A A

ˆ ˆx a(a x)= ⋅ x x′ =c Mc oRay casting. 3D Transformations â€¢ Same idea as 2D transformations oHomogeneous coordinates: (x,y,z,w)
Documents 2D and 3D Transformations, Homogeneous Coordinates ... and 3D Transformations, Homogeneous Coordinates Lecture 03 Patrick Karlsson @cb.uu.se Centre for Image Analysis Uppsala University
Documents 3D Transformations - Computer Science - Drexel Graphics 3D Transformations ... • World window to viewport transformation • 3D transformations ... • Euler Angles have problems
Documents Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation
Documents Today Composing transformations 3D Transformations Homogeneous coordinates Intro to Viewing
Documents 1 3D Transformations CS 234 Jeff Parker. 2 Objectives Notifications Homework Gallery Pen and Paper Review transformations Apply these ideas to 3D movement
Documents Geometric transformations in 3D and coordinate Geometric transformations in 3D and coordinate frames
Documents Western Heritage II Journeys and Transformations 5 WESTERN HERITAGE II Journeys and Transformations
Documents Documents