• No results found

TNM046: Datorgrafik Transformations

N/A
N/A
Protected

Academic year: 2021

Share "TNM046: Datorgrafik Transformations"

Copied!
53
0
0

Loading.... (view fulltext now)

Full text

(1)

TNM046: Datorgrafik Transformations

Sasan Gooran

VT 2013

(2)

Computer Graphics

What?

“Almost everything on computers that is not text or sound “ The representation and manipulation of image data by

computer

Techniques to create and manipulate images

Where?

Television, Newspapers (weather reports), Medical investigations and surgical procedures

(3)

3

Computer Graphics

Applications:

Entertainments (Movies, Video games) Computer Aided Design (CAD)

Medical Applications Scientific Visualization Virtual Reality

….

(4)

Computer Graphics

(5)

5

Computer Graphics, TNM046

2D and 3D Transformations Triangle and Normal

Light Sources and Shading Perspective Projection

Culling and Clipping Texture Mapping

(6)

Linear Algebra

Transposition

x =

(

x1, x2, x3

)

Scalar (dot) product:

xt =

x1 x2 x3

!

"

##

##

$

%

&

&

&&

yt =

y1 y2 y3

!

"

##

##

$

%

&

&

&&

y =

(

y1, y2, y3

)

x • 

y =x ∗

yt = x1y1 + x2y2 + x3y3

Length (Norm):

x = x • x = x 12 + x22 + x32

Normalization:

ˆx =

x

(7)

7

Linear Algebra

x = 1, 2, 2

( )

y =

(

−1, 2, −2

)

Example: Find the angle between the two vectors below!

(answer: 1.68 radians or 96.38 degrees)

x • 

y =

x ⋅

y ⋅ cos(θ)

x • 

y > 0 →θ < 90 x • 

y = 0 →θ = 90 x • 

y < 0 →θ > 90

"

#$$

%

$$

(8)

Linear Algebra

Cross (vector) product:

x × 

y = ( x2y3 − x3y2 x3y1 − x1y3 x1y2 − x2y1 ) x × 

y =

ˆx ˆy ˆz

x1 x2 x3 y1 y2 y3

xyx × 

y

xy

 

x × 

y =

x ⋅

y ⋅ sin(θ) (

x ×

y)•

x = ?

  

(9)

9

Basic Transformations (2D)

Translation

P1

P2 T

P1 = x1 y1

!

"

##

$

%

&

& P2 = x2 y2

!

"

##

$

%

&

&

T = ( tx, ty )

O

x2 = x1 + tx y2 = y1 + ty

!

"

#

$#

OP2 = →OP1 + →T

x y

à

(10)

Basic Transformations (2D)

Translation

What is the translation vector, from A to B?

from B to A?

15 5

3 6

A

5 8

B

(11)

11

Basic Transformations (2D)

Rotation

P1 = x1 y1

!

"

##

$

%

&

&

P2 = x2 y2

!

"

##

$

%

&

&

ϕ

θ r

r

x2 = r cos(ϕ +θ) = r cosϕ cosθ − r sinϕ sinθ y2 = r sin(ϕ +θ) = r sinϕ cosθ + r cosϕ sinθ

"

#$

%$

x1 = r cosϕ y1 = r sinϕ

!

"

#

$#

x2 = x1 cosθ − y1sinθ y2 = x1 sinθ + y1 cosθ

"

#$

%$

(12)

Basic Transformations (2D)

Rotation

x2 y2

!

"

##

$

%

&

& = cosθ −sinθ

sinθ cosθ

!

"

# $

%& x1 y1

!

"

##

$

%

&

&

P2 = R ∗ P1

Counter-clockwise rotation by angle θ about the coordinate origin

à

(13)

13

Basic Transformations (2D)

Rotation

P1 = x1 y1

!

"

##

$

%

&

&

P2 = x2 y2

!

"

##

$

%

&

&

θ r

r

Rotation about an arbitrary point M

x2 = xM + (x1 − xM )cosθ − (y1 − yM )sinθ y2 = yM + (x1 − xM )sinθ + (y1 − yM )cosθ

"

#$

%$

M = xM yM

!

"

##

$

%

&

&

(14)

Basic Transformations (2D)

Scaling

Fixed point: Coordinate origin

x2 = sx ⋅ x1 y2 = sy ⋅ y1

"

#$

%$

P2 = S ∗ P1 S = sx 0

0 sy

!

"

##

$

%

&

&

à where

sx and sy > 0

Scaling values less than 1 reduces the size of the object Scaling values greater than 1 produce an enlargement

sx=sy: Uniform scaling, which maintains the relative object properties

(15)

15

Basic Transformations (2D)

Scaling

Arbitrary fixed point: (xf, yf) x2 = xf + sx ⋅ (x1 − xf ) y2 = yf + sy ⋅ (y1 − yf )

#

$%

&%

4 1

1 2

2 4

Object

Scaled sx=sy=2

Scaled sx=sy=0.5

fixed point: (0, 0)

4 1

1 2

2

Object Scaled sx=sy=2

Scaled sx=sy=0.5

fixed point: (2, 1) 3

(16)

Matrix representation

Homogenous coordinates (translation)

x2 y2

!

"

##

$

%

&

& = x1 y1

!

"

##

$

%

&

&+ tx ty

!

"

##

$

%

&

&

In order to represent this with a matrix multiplication we add a third coordinate, 1.

x2 y2 1

!

"

##

##

$

%

&

&

&& =

1 0 tx

0 1 ty

0 0 1

!

"

##

##

$

%

&

&

&&

x1 y1 1

!

"

##

##

$

%

&

&

&&

P2 = T ∗ P1 à

(17)

Matrix representation

Homogenous coordinates (translation)

T is the translation matrix. What is the inverse matrix?

T =

1 0 tx

0 1 ty

0 0 1

!

"

##

##

$

%

&

&

&&

T−1 = ?

17

(18)

Matrix representation

Homogenous coordinates (Rotation)

x2 y2 1

!

"

##

##

$

%

&

&

&& =

cosθ −sinθ 0

sinθ cosθ 0

0 0 1

!

"

##

#

$

%

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&&

P2 = R ∗ P1

R is the rotation matrix. What is the inverse matrix?

R−1 = ?

(19)

Matrix representation

Homogenous coordinates (Scaling)

x2 y2 1

!

"

##

##

$

%

&

&

&& =

sx 0 0

0 sy 0

0 0 1

!

"

##

##

$

%

&

&

&&

x1 y1 1

!

"

##

##

$

%

&

&

&&

P2 = S ∗ P1

S is the scaling matrix. What is the inverse matrix?

S−1 = ?

19

(20)

Composite Transformation

P2 = T (tx 2, ty2)∗ T (t

{

x1, ty1)* P1

}

= T (t

{

x 2, ty2)∗T (tx1, ty1)

}

* P1

If two successive translation vectors (tx1, ty1) and (tx2, ty2)

are applied to a coordinate position P1, the final transformed location P2 is calculated:

1 0 tx 2

0 1 ty2

0 0 1

!

"

##

##

$

%

&

&

&&

1 0 tx1

0 1 ty1

0 0 1

!

"

##

##

$

%

&

&

&& =

1 0 tx1 + tx 2 0 1 ty1 + ty2

0 0 1

!

"

##

##

$

%

&

&

&&

(21)

Composite Transformation

P2 = R(θ2)∗ R(

{

θ1)* P1

}

= R(

{

θ2)∗ R(θ1)

}

* P1 = R(θ1 +θ2)* P1

Two successive Rotations by θ1 and θ2:

sx 2 0 0

0 sy2 0

0 0 1

!

"

##

##

$

%

&

&

&&

sx1 0 0

0 sy1 0

0 0 1

!

"

##

##

$

%

&

&

&& =

sx1 ⋅ sx 2 0 0 0 sy1 ⋅ sy2 0

0 0 1

!

"

##

##

$

%

&

&

&&

Two successive Scaling-s:

21

(22)

General Pivot-Point Rotation

Rotation about an arbitrary point (xM, yM):

x2 y2 1

!

"

##

##

$

%

&

&

&& =

1 0 xM

0 1 yM

0 0 1

!

"

##

##

$

%

&

&

&&

cosθ −sinθ 0

sinθ cosθ 0

0 0 1

!

"

##

#

$

%

&

&

&

1 0 −xM

0 1 −yM

0 0 1

!

"

##

##

$

%

&

&

&&

x1 y1 1

!

"

##

##

$

%

&

&

&&

Step 1: Translate (xM, yM) to the coordinate origin (0,0) Step 2: Rotate about (0, 0)

Step 3: Translate back to (xM, yM)

x2 y2

!#

#

##

$&

&

&& =

cosθ −sinθ xM (1− cosθ) + yM sinθ sinθ cosθ yM (1− cosθ) − xM sinθ

!#

#

##

$&

&

&&

x1 y1

!#

#

##

$&

&

&&

(23)

General Fixed-Point Scaling

Scaling about an arbitrary point (xf, yf):

x2 y2 1

!

"

##

##

$

%

&

&

&& =

1 0 xf

0 1 yf

0 0 1

!

"

##

##

$

%

&

&

&

&

sx 0 0

0 sy 0

0 0 1

!

"

##

##

$

%

&

&

&&

1 0 −xf

0 1 −yf

0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&&

Step 1: Translate (xf, yf) to the coordinate origin (0,0) Step 2: Scale about (0, 0)

Step 3: Translate back to (xf, yf)

x2 y2 1

!

"

##

##

$

%

&

&

&& =

sx 0 xf (1− sx) 0 sy yf (1− sy)

0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&& 23

(24)

Ex: General Scaling Directions

We can scale an object in other directions by rotating the object to align the desired scaling directions

x y

S1 S2

θ Step 1: Rotate the object (by θ) to align

Step 2: Scale in the direction of (x, y)

(25)

Ex: General Scaling Directions

x2 y2 1

!

"

##

##

$

%

&

&

&&=

cosθ sinθ 0

−sinθ cosθ 0

0 0 1

!

"

##

#

$

%

&

&

&

s1 0 0

0 s2 0

0 0 1

!

"

##

##

$

%

&

&

&&

cosθ −sinθ 0

sinθ cosθ 0

0 0 1

!

"

##

#

$

%

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&&

x2 y2 1

!

"

##

##

$

%

&

&

&& =

s1 cos2θ + s2 sin2θ (s2 − s1)sinθ cosθ 0 (s2 − s1)sinθ cosθ s1sin2θ + s2 cos2θ 0

0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&&

What happens when s1=s2?

25

(26)

Reflection

1 0 0

0 −1 0

0 0 1

"

#

$$

$

%

&

'' '

Reflection matrix about y=0 (x-axis)

−1 0 0

0 1 0

0 0 1

"

#

$$

$

%

&

'' '

Reflection matrix about x=0 (y-axis)

−1 0 0

0 −1 0

0 0 1

"

$$

$

%' ''

Reflection relative to the coordinate origin

(27)

Ex: Reflection along y=x

Step 1: Rotate counter clockwise (45 degrees) (y=x) à y-axis

Step 2: Reflect bout y-axis Step 3: Rotate back

x2 y2 1

!

"

##

##

$

%

&

&

&&=

cosθ sinθ 0

−sinθ cosθ 0

0 0 1

!

"

##

#

$

%

&

&

&

−1 0 0

0 1 0

0 0 1

!

"

##

#

$

%

&

&

&

cosθ −sinθ 0

sinθ cosθ 0

0 0 1

!

"

##

#

$

%

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&&

θ = π / 4 x2

y2 1

!

"

##

##

$

%

&

&

&& =

0 1 0 1 0 0 0 0 1

!

"

##

#

$

%

&

&

&

x1 y1 1

!

"

##

##

$

%

&

&

&& 27

(28)

Shear

x2 y2 1

!

"

##

##

$

%

&

&

&& =

1 shx 0

0 1 0

0 0 1

!

"

##

##

$

%

&

&

&&

x1 y1 1

!

"

##

##

$

%

&

&

&&

x2 = x1 + shx ⋅ y1 y2 = y1

"

#$

%$

1 1

shx = 2

(29)

3D transformations, Translation

x2 y2 z2 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

29

(30)

3D Rotation

x

P2 =

x2 = a y2 z2

!

"

##

##

$

%

&

&

&&

θ r r

y z

About x-axis

Counter clockwise

P1 =

x1 = a y1 z1

!

"

##

##

$

%

&

&

&&

When rotating around x-axis the x-coordinate is unchanged

(31)

3D Rotation

x2 y2 z2 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 0

0 cosθ −sinθ 0

0 sinθ cosθ 0

0 0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

Rotation about x-axis:

x2 y2 z2 1

!

"

##

##

#

$

%

&

&

&

&

&

=

cosθ 0 sinθ 0

0 1 0 0

−sinθ 0 cosθ 0

0 0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

Rotation about y-axis:

Why changing the signs in front of sinθ?

Rotation matrix about z-axis?

31

(32)

General 3D Rotation

Rotation about an axis parallel to one of the coordinate axes Step 1: Translate so that the rotation axis coincides with the parallel coordinate axis

Step 2: Perform the specified rotation about that axis Step 3: Translate back

R(α) = T−1 ∗ Rco−axis)*T

(33)

General 3D Rotation

Example: Counterclockwise rotation by 30 degrees about the axis passing through M1:(2, 1, 3) and M2:(2, 2, 3)

(vector from M1 to M2)

The vector going from M1 to M2 is (2 2 3)-(2 1 3)=(0 1 0), which is obviously parallel to y-axis

R(θ) =

1 0 0 2 0 1 0 1 0 0 1 3 0 0 0 1

!

"

##

##

$

%

&

&

&

&

cos(π

6 ) 0 sin(π

6 ) 0

0 1 0 0

−sin(π

6 ) 0 cos(π

6 ) 0

0 0 0 1

!

"

##

##

##

#

$

%

&

&

&

&

&

&

&

1 0 0 −2 0 1 0 −1 0 0 1 −3

0 0 0 1

!

"

##

##

$

%

&

&

&

&

Are there any other translations that work? 33

(34)

General 3D Rotation

Rotation about an axis that is not parallel to any coordinate axes Step 1: Translate the object so that the rotation axis passes through the coordinate origin

Step 2: Rotate the object so that the axis of rotation coincides with one of the coordinate axes

Step 3: Perform the specified rotation about the coordinate axis Step 4: Rotate back

Step 5: Translate back

R(α) = T−1 ∗ Raxis −>co−axis

−1 ∗ Rco−axis)∗ Raxis−>co−axis ∗T

(35)

General 3D Rotation

x

M2 =

xm2 ym2 zm2

!

"

##

##

$

%

&

&

&&

y z

M1 =

xm1 ym1 zm1

!

"

##

##

$

%

&

&

&

&

Eye

U =

M1M2 = (xm2 − xm1, ym2 − ym1, zm2 − zm1)

ˆu = U

U = (a, b, c) The vector is normalized

a2 + b2 + c2 = ? 35

(36)

General 3D Rotation

x

y z

After translation

(Step 1) ˆu = (a, b, c)

T =

1 0 0 −xm1

0 1 0 −ym1

0 0 1 −zm1

0 0 0 1

"

#

$$

$$

$

%

&

'' '' '

(37)

General 3D Rotation

x

y z

ˆu = (a, b, c)

Two rotations are needed to make u coincide with one of the coordinate axes. (step 2)

Here we find the rotations to coincide it with z-axis

v = (a, b, 0) ϕ

The first rotation

is about the z-axis by φ to rotate u to the xz-plane (clockwise)

θ

The second rotation is about the y-axis by θ to align that with z-axis (clockwise)

37

(38)

General 3D Rotation

y z

ˆu = (a, b, c)

v = (a, b, 0) ϕ

The first rotation:

ˆx •

v = ˆx ⋅

v cosϕ = a2 + b2 cosϕ ˆx •

v = (1, 0, 0)⋅ (a, b, 0) = a à cosϕ = a d set d = a2 + b2

ˆx ×

v = (1, 0, 0) × (a, b, 0) = (0, 0, b) ˆx ×

v = ˆx ⋅

v sinϕ = a2 + b2 sinϕ sinϕ = b

d

(39)

General 3D Rotation

The second rotation:

ˆz• ˆu = ˆz ⋅ ˆu cosθ = cosθ

ˆz• ˆu = (0, 0,1)⋅ (a, b, c) = c à cosθ = c

sinθ = 1− cos2θ = 1− c2 = d

x

y z

ˆu = (a, b, c) θ

Since 0 ≤θ ≤ π then sinθ ≥ 0

Observe: a2 + b2 + c2 = 1 and d = a2 + b2

39

(40)

General 3D Rotation

R(α) = T−1 ∗ Raxis −>co−axis

−1 ∗ Rco−axis)∗ Raxis−>co−axis ∗T

Raxis−>co−axis =

cosθ 0 −sinθ 0

0 1 0 0

sinθ 0 cosθ 0

0 0 0 1

"

#

$$

$$

%

&

'' ''

cosϕ sinϕ 0 0

−sinϕ cosϕ 0 0

0 0 1 0

0 0 0 1

"

#

$$

$$$

%

&

'' '''

Raxis−>co−axis =

c 0 −d 0

0 1 0 0

d 0 c 0

"

$$

$

%' ''

a / d b / d 0 0

−b / d a / d 0 0

0 0 1 0

"

$$

$

%' ''

Notice: Clockwise rotations Step 2

(41)

General 3D Rotation

R(α) = T−1 ∗ Raxis −>co−axis

−1 ∗ Rco−axis)∗ Raxis−>co−axis ∗T

Raxis−>co−axis

−1 =

a / d −b / d 0 0 b / d a / d 0 0

0 0 1 0

0 0 0 1

"

#

$$

$$

%

&

'' ''

c 0 d 0

0 1 0 0

−d 0 c 0

0 0 0 1

"

#

$$

$$

%

&

'' ''

Why?

T−1 =

1 0 0 xm1

0 1 0 ym1

0 0 1 zm1

0 0 0 1

"

#

$$

$$

$

%

&

'' '' '

41

Step 4

Step 5

(42)

General 3D Rotation

R(α) = T−1 ∗ Raxis −>co−axis

−1 ∗ Rco−axis)∗ Raxis−>co−axis ∗T

Rco−axis =

cos(α) −sin(α) 0 0

sin(α) cos(α) 0 0

0 0 1 0

0 0 0 1

"

#

$$

$$$

%

&

'' '''

Notice that in the approach presented here we coincided the axis of rotation with z-axis. Therefore the coordinate axis is z-axis.

Step 3

(43)

Parallel Projection

Just to make it consistent with the assignments in the labs, here we rearranged the x, y and z-axes. The xy plane is the view plane and the z-axis points towards the viewer.

If the parallel projection on the view plane

(xy-plane or z=0) occurs along the z-direction, then:

z

x y

P1 = x1 y1 z1

!

"

##

##

$

%

&

&

&&

P2 =

x2 y2 z2

!

"

##

##

$

%

&

&

&&

x2 = x1 y2 = y1 z2 = 0

!

"

#

$

##

x2 y2 z2 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

43

(44)

Parallel Projection

z

x y

If the view plane is parallel to xy-plane, z=zv.

If the parallel projection on the view plane (z=zv) occurs along the z-direction, then:

P1 = x1 y1 z

!#

###

$&

&

&&

x2 = x1 y2 = y1 z2 = zv

!

"

#

$#

#

x2 y2 z2

!#

##

##

$&

&

&

&

&

=

1 0 0 0

0 1 0 0

0 0 0 zv

!#

##

#

$&

&

&

&

x1 y1 z1

!#

##

##

$&

&

&

&

&

P2 =

x2 y2 z2

!

"

##

##

$

%

&

&

&&

(45)

Coordinate System Transformation

z

x

y N

U V

The axes of the two coordinate systems are parallel.

O

O' =

xo' yo' zo'

!

"

##

##

$

%

&

&

&

&

Assume that a point P has coordinates x

(

1, y1, z1

)

t in World

and coordinates u

(

1, v1, n1

)

t in View coordinate system.

World

View

T =

1 0 0 −xo'

0 1 0 −yo'

0 0 1 −zo'

0 0 0 1

"

#

$$

$$

$

%

&

'' '' '

T transforms (translates) View system to World system.

45

(46)

Coordinate System Transformation

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 xo'

0 1 0 yo'

0 0 1 zo'

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

u1 v1 n1 1

!

"

##

##

#

$

%

&

&

&

&

&

u1 v1 n1 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 −xo'

0 1 0 −yo'

0 0 1 −zo'

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

In order not to get confused think of the coordinates of the origin of the View

system (O’), which is (0,0,0) in View, but

O' = x

(

o', yo', zo'

)

t

in World system.

The axes of the two coordinate systems are parallel.

View World

(47)

Coordinate System Transformation

z

x

y N

U V

One of the axes are parallel (here z and N) but UV plane is rotated by θ in relation to xy palne.

O

O' = x( o', yo', zo')t World

View The view coordinate

system is transformed to World by a translation followed by a clockwise rotation about z-axis.

θ

47

(48)

Coordinate System Transformation

The z-axes are parallel but xy are rotated by θ.

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 xo'

0 1 0 yo'

0 0 1 zo'

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

cosθ −sinθ 0 0

sinθ cosθ 0 0

0 0 1 0

0 0 0 1

!

"

##

##

$

%

&

&

&

&

u1 v1 n1 1

!

"

##

##

#

$

%

&

&

&

&

&

u1 v1 n1 1

!

"

##

##

#

$

%

&

&

&

&

&

=

cosθ sinθ 0 0

−sinθ cosθ 0 0

0 0 1 0

0 0 0 1

!

"

##

##

$

%

&

&

&

&

1 0 0 −xo'

0 1 0 −yo'

0 0 1 −zo'

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

View World

(49)

Coordinate System Transformation

None of the axes are parallel

z

x

y N

U V

O

O' = x( o', yo', zo')t World

View First a translation is needed. Assume then that the unit vectors of the

coordinate axes of the View system can be expressed in World

coordinates.

ˆu = (ux, uy, uz) ˆv = (vx, vy, vz)

ˆn = (nx, ny, nz)

49

(50)

Coordinate System Transformation

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

=

1 0 0 xo'

0 1 0 yo'

0 0 1 zo'

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

ux vx nx 0 uy vy ny 0 uz vz nz 0

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

u1 v1 n1 1

!

"

##

##

#

$

%

&

&

&

&

&

u1 v1 n1 1

!

"

##

##

#

$

%

&

&

&

&

&

=

ux uy uz 0 vx vy vz 0 nx ny nz 0

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

1 0 0 −xo'

0 1 0 −yo'

0 0 1 −zo'

0 0 0 1

!

"

##

##

#

$

%

&

&

&

&

&

x1 y1 z1 1

!

"

##

##

#

$

%

&

&

&

&

&

View World

None of the axes are parallel

(51)

Coordinate System Transformation

Few points:

In order to better understand the transformations in previous page, think of a point that has the coordinate (0,0,1) in the View system, then you can see that it is first transformed to (nx,ny,nz) and then translated.

What is the World coordinates of a point with coordinates (1,0,0) in the View system?

Make sure that you have understood these transformations by trying some obvious coordinates.

Notice that the inverse of a matrix whose rows (or columns) make an orthonormal base is equal to its transpose.

51

(52)

Coordinate System Transformation

x y

N V’

O

O' = x( o', yo', zo')t World

View

In practice you usually have the position of the camera (O’), the direction it is looking towards (N) and an up direction (V’) which is not necessarily perpendicular to N. If we now find an orthonormal base for the View system then we have the transformation matrix.

(53)

Coordinate System Transformation

z

x y

N V’

O World

ˆn = N

N = (nx, ny, nz)

In some literature this might be defined as ˆn = − N N

Then U has to be perpendicular to the plane of N and V’:

ˆu =

V '×

N V '×

N = (ux, uy, uz)

U

V has to be perpendicular to both U and N.

ˆv = ˆn × ˆu = (vx, vy, vz)

V

The transformations are now as shown on Page 50 53

References

Related documents

A convex hull of the centres of its faces creates triangles, and because the solid has both four vertices and four faces, the result is a tetrahedron upside down as seen in Figure

When Stora Enso analyzed the success factors and what makes employees &#34;long-term healthy&#34; - in contrast to long-term sick - they found that it was all about having a

You suspect that the icosaeder is not fair - not uniform probability for the different outcomes in a roll - and therefore want to investigate the probability p of having 9 come up in

Notice that the inverse of a matrix whose rows (or columns) make an orthonormal base is equal to its transpose.. If we now find an orthonormal base for the View system then we

Rotation about an axis parallel to one of the coordinate planes Step 1: Translate the object so that the rotation axis passes through the coordinate origin. This vector is now on

instrument, musical role, musical function, technical challenges, solo role, piccolo duo, orchestration, instrumentation, instrumental development, timbre, sonority, Soviet

Instead of the conventional scale invariant approach, which puts all the scales in a single histogram, our representation preserves some multi- scale information of each

The focus is on the Victorian Environmental Water Holder (VEWH), that gives entitlements to the environmental water of the Yarra river, and on the Yarra River Protection