• No results found

Linear Algebra

N/A
N/A
Protected

Academic year: 2021

Share "Linear Algebra "

Copied!
18
0
0

Loading.... (view fulltext now)

Full text

(1)

TNM046: Datorgrafik Transformations

Sasan Gooran

VT 2014

2

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 = x1 2+ x2

2+ x3 2

Normalization: ˆx =

x

x

3

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

"

#$$

%

$

$

(2)

4

Linear Algebra

Cross (vector) product:

x × 

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

y =

ˆx ˆy ˆz

x1 x2 x3 y1 y2 y3

x

y

x ×y

x

y

y ×  x

x ×  y =

x ⋅y ⋅ sin(θ )

(x ×y)• x = ? (

x ×y)•

y = ?

5

Basic Transformations (2D)

Translation

P1

P2 TP1= x1

y1

!

"

##

$

%

&

& P2= x2 y2

!

"

##

$

%

&

&

T = ( tx, ty )

O

x2= x1+ tx y2= y1+ ty

!

"

#

$#

OP2 = →OP1 + →T

x y

à

Basic Transformations (2D)

Translation

What is the translation vector, from A to B?

from B to A?

15 5

3 6

A

12 2

5 8

B

6

(3)

7

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= x1cosθ − y1sinθ y2= x1sinθ + y1cosθ

"

#$

%$

Basic Transformations (2D)

Rotation

x2 y2

!

"

##

$

%

&

&= cosθ −sinθ

sinθ cosθ

!

"

# $

%

& x1 y1

!

"

##

$

%

&

&

P2= R ∗ P1

Counter-clockwise rotation by angle θ about the coordinate origin

à

8

9

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

!

"

##

$

%

&

&

(4)

10

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

11

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 2

1 2

Object Scaled sx=sy=2

Scaled sx=sy=0.5

fixed point: (2, 1) 3

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 à

12

(5)

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= ?

13

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= ?

14

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= ?

15

(6)

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

!

"

#

###

$

%

&

&

&&

16

Composite Transformation

P2= R(θ2)∗ R(θ{ 1)* P1}= R(θ{ 2)∗ R(θ1)}* P1= R(θ12)* 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:

17

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

1

!

"

#

#

##

$

%

&

&

&&=

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

0 0 1

!

"

#

#

##

$

%

&

&

&&

x1 y1

1

!

"

#

#

##

$

%

&

&

&& 18

(7)

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

!

"

##

##

$

%

&

&

&& 19

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) Step 3: Rotate back

20

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

!

"

#

###

$

%

&

&

&&=

s1cos2θ + s2sin2θ (s2− s1)sinθ cosθ 0 (s2− s1)sinθ cosθ s1sin2θ + s2cos2θ 0

0 0 1

!

"

##

##

$

%

&

&

&

&

x1 y1 1

!

"

#

###

$

%

&

&

&&

What happens when s1=s2?

21

(8)

Reflection

1 0 0

0 −1 0

0 0 1

"

#

$

$$

%

&

' '' Reflection matrix across y=0 (x-axis)

−1 0 0

0 1 0

0 0 1

"

#

$

$$

%

&

' '' Reflection matrix across x=0 (y-axis)

−1 0 0

0 −1 0

0 0 1

"

#

$

$$

%

&

' '' Reflection relative to the coordinate origin

22

Ex: Reflection in y=x

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

Step 2: Reflect across the 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

!

"

#

#

##

$

%

&

&

&& 23

Shear

x2 y2 1

!

"

#

###

$

%

&

&

&&=

1 shx 0

0 1 0

0 0 1

!

"

#

###

$

%

&

&

&&

x1 y1 1

!

"

#

###

$

%

&

&

&&

x2= x1+ shx⋅ y1

y2= y1

"

#$

%$

1 1

1 1

2 3

shx= 2

24

(9)

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

!

"

#

#

##

#

$

%

&

&

&

&

&

25

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

26

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? 27

(10)

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

28

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(π 6) =

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? 29

General 3D Rotation

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 one of the coordinate planes.

Step 2: Rotate the object so that the axis of rotation coincides with one of the coordinate axes (one rotation is needed) Step 3: Perform the specified rotation about that axis Step 4: Rotate back

Step 5: Translate back

30

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

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

(11)

General 3D Rotation

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

(vector from M1 to M2)

The vector going from M1 to M2 is (2 2 4)-(2 1 3)=(0 1 1), which is obviously parallel to YZ-plane (The translation is as before) It is easily seen that if we rotate (0, 1, 1) by 45 degrees and counterclockwise around X-axis, it will coincide with the Z-axis.

Raxis−>co _ axis=

1 0 0 0

0 cos(π 4) −sin(π

4) 0 0 sin(π

4) cos(π

4) 0

0 0 0 1

"

#

$$

$

$$

$$

%

&

'' ' '' ''

31

General 3D Rotation

Example: Continuation

R = T−1

1 0 0 0

0 cos(π

4) sin(π

4) 0

0 −sin(π

4) cos(π 4) 0

0 0 0 1

"

#

$$

$$

$

$$

%

&

'' '' ' ''

cos(π 6) −sin(π

6) 0 0

sin(π 6) cos(π

6) 0 0

0 0 1 0

0 0 0 1

"

#

$$

$$

$

$$

%

&

'' '' ' ''

1 0 0 0

0 cos(π 4) −sin(π

4) 0 0 sin(π

4) cos(π

4) 0

0 0 0 1

"

#

$$

$$

$

$$

%

&

'' '' ' '' T

32

Where,

T =

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

0 0 0 1

"

#

$

$

$$

%

&

' ' ''

General 3D Rotation

Rotation about an arbitrary axis that is not parallel to any coordinate axes, or coordinate planes.

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 (two rotations are needed) 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

33

(12)

General 3D Rotation

M2= xm2 ym2

zm2

!

"

##

##

$

%

&

&

&

&

x

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= ? 34

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

"

#

$

$$

$$

%

&

' '' ''

35

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)

36

(13)

General 3D Rotation

x

y z

ˆu = (a, b, c)

v = (a, b, 0) ϕ

The first rotation:

ˆx •v = ˆx ⋅

v cosϕ = a2+ b2cosϕ ˆx •

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

sinϕ = ± 1− (a d)2= ±b

d

37

if b > 0 --> 0 ϕ  π --> sinϕ  0 if b < 0 --> π ϕ  2π --> sinϕ  0

Therefore:

sinϕ =b d

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

38

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

0 0 0 1

"

#

$

$

$$

%

&

' ' ''

a / d b / d 0 0

−b / d a / d 0 0

0 0 1 0

0 0 0 1

"

#

$

$

$$

%

&

' ' ''

Notice: Clockwise rotations

39

Step 2

(14)

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

"

#

$

$

$$

$

%

&

' ' '' '

40 Step 4

Step 5

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.

41 Step 3

General 3D Rotation Exercises

42

Exercise 1: Counterclockwise rotation by α about the axis passing through M1:(1, 2, 3) and M2:(1, 1, 5) (vector from M1 to M2)

Exercise 2: Counterclockwise rotation by α about the axis passing through M1: (0, 0, 0) and M2: (-2, 3, -6) (vector from M1 to M2)

(15)

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

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 z1

!

"

#

###

$

%

&

&

&&

x2= x1

y2= y1

z2= zv

!

"

#

$

##

x2

y2 z2 1

!

"

#

#

##

#

$

%

&

&

&

&

&

=

1 0 0 0

0 1 0 0

0 0 0 zv

0 0 0 1

!

"

##

#

#

$

%

&

&

&

&

x1

y1 z1 1

!

"

#

#

##

#

$

%

&

&

&

&

&

P2= x2 y2

z2

!

"

##

##

$

%

&

&

&&

44

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

(16)

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

World View 46

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 plane.

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

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

World View 48

(17)

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

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

World View

None of the axes are parallel

50

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

(18)

Coordinate System Transformation

z

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.

52

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

Previous studies proposed a prospective account of two-step actions (Claxton et al. 2017): The first action step is influenced by the second step; indicating infants’ motor

Mean deflection (angle z ) and direction (angle xy ) in degrees (SD) and 95 % confidence interval (CI) for the rotation axes at the basal, mid and apical levels measured in 39

The aims of this thesis were to describe the rotation pattern of the LV in detail (study I), to assess RV apical rotation (study II), develop a method to assess the 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

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

Hypothesis I: A firm which undergoes a listing change from Nasdaq First North to the Swedish main market Stockholm stock exchange is expected to experience an increase in the number

Stöden omfattar statliga lån och kreditgarantier; anstånd med skatter och avgifter; tillfälligt sänkta arbetsgivaravgifter under pandemins första fas; ökat statligt ansvar

The experiences of nurses in Sub-Saharan Africa who care for PLWHA showed that nurses faced challenges like lack of human and material resources, negative attitudes mostly