19
©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical 3-D Mathematical Preliminaries Preliminaries & Transformations & Transformations

©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

Embed Size (px)

Citation preview

Page 1: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

1

3-D Mathematical Preliminaries3-D Mathematical Preliminaries& Transformations& Transformations

Page 2: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

2

Coordinate Systems

Z

X

YY

X

Z

Right-handed coordinate

system

Left-handedcoordinate

system

Page 3: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

3

Parametric Definition of a Line

Given two points P1 = (x1, y1, z1), P2 = ( x2, y2, z2)

x = x1 + t (x2 - x1)

y = y1 + t (y2 - y1)

z = z1 + t (z2 - z1)

Given a point P1 and a vector V = [xv, yv, zv]

x = x1 + t xv, y = y1 + t yv , z = z1 + t zv

COMPACT FORM: L = P1 + t[P2 - P1] or L = P1 + Vt

P1

P2

t = 1

t = 0

t > 1

t < 0

Page 4: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

4

3-D VectorsHave length and direction V = [xv, yv, zv]

Length is given by the Euclidean Norm ||V|| = sqrt( xv2 + yv

2 + zv2 )

Dot Product V•U = [xv, yv, zv] • [xu, yu, zu] = xvxu + yvyu + zvzu

= ||V|| ||U|| cos ß

Cross Product V x U = [vyuz - vzuy, -vxuz + vzux, vxuy - vyux]

V x U = - ( U x V)

Direction of resulting vector depends on coordinate system and

order of vectors.

Page 5: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

5

Derivation of Plane Equation

P1

P2

P3

To derive equation of the plane given three points: P1, P2, P3

[ P3 - P1] x [ P2 - P1] = N, orthogonal vector

Given a general point P = (x,y,z)

N • [P - P1] = 0 if P is in the plane.

Or given a point (x,y,z) in the plane and normal vector N then N • [x,y,z] = -D

Page 6: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

6

Equation of a planeAx + By + Cz + D = 0

Alternate Form: A'x + B'y + C'z +D' = 0

where A' = A/d, B' = B/d, C' = C/d, D' = D/d

d = sqrt(A2 + B2 + C2)

Distance between a point and the plane is given by

A'x + B'y + C'z +D' (sign indicates which side)

Given Ax + By + Cz + D = 0 Then [A, B, C] is a normal vector

Pf: Given two point P1 and P2 in the plane, the vector [ P2 - P1] is in the plane and [A,B, C] • [ P2 - P1] = (Ax2 + By2 +Cz2) - (Ax1 + B y1 + Cz1) = ( - D ) - ( - D ) = 0

Page 7: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

7

Basic Transformations

•Translation

•Scale

•Rotation

•Shear

Page 8: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

8

Translation in Homogeneous Coordinates

[T][P] = (x + tx, y + ty, z + tz)

(1 0 0 tx) (x)

(0 1 0 ty) (y)

(0 0 1 tz ) (z)

(0 0 0 1 ) (1)

T P

Page 9: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

9

Scale

[S][P] = (sxx, syy, szz)

(sx 0 0 0) (x)

(0 sy 0 0) (y)

(0 0 sz 0) (z)

(0 0 0 1) (1)

Note: A scale may also translate an object!

Page 10: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

10

RotationsPositive Rotations are defined as follows

Axis of rotation is Direction of positive rotation is

x y to z

y z to x

z x to y

Z

Y

X

Page 11: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

11

Rotations

About the z axis Rz(ß) P =

(cosß -sinß 0 0)(x)

(sinß cosß 0 0)(y)

(0 0 1 0) (z)

(0 0 0 1)(1)

About the x axis Rx(ß) P =

(1 0 0 0)(x)

(0 cosß -sinß 0)(y)

(0 sinß cosß 0) (z)

(0 0 0 1)(1)

About the y axis Ry(ß) P =

( cosß 0 sinß 0)(x)

(0 1 0 0)(y)

(-sinß 0 cosß 0) (z)

(0 0 0 1)(1)

Page 12: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

12

Shears

xy Shear

SHxyP = (1 0 shx 0) (x)

(0 1 shy 0) (y)

(0 0 1 0) (z)

(0 0 0 1) (1)

Page 13: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

13

A Rotation Φ About An Arbitrary Axis

Z

P1

P2

Y

X

Page 14: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

14

A Rotation Φ About An Arbitrary Axis1. Translate one end of the axis to the origin

[P2-P1] = [ u1, u2, u3] Z

P1

P2

Y

X

Page 15: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

15

A Rotation Φ About An Arbitrary Axis

a = sqrt(u12 + u3

2)

b = sqrt(u12 + u2

2)

c = sqrt(u22 + u3

2)

cosß = u3/a

sinß = u1/a

1. Translate one end of the axis to the origin

[P2-P1] = [ u1, u2, u3] Z

Y

X

b

a

c

u1

u2

u3

ß

U

Page 16: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

16

2. Rotate the coordinate axes about the y-axis an angle -ß

After Ry(-ß), U lies in the y-z plane

Z

Y

X

b

a

c

u1

u2

u3

Z

Y

X

µ

u2

a

ß

U

U

Page 17: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

17

3. Rotate the coordinate axes about the x-axis through an angle µ to align the z-axis with U

Rx (µ)

cos µ = a/ ||u||

UZ

Y

X

µ

U

Z

Y

XAfter Rx(µ), U lies on the z-axis

Page 18: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

18

4 . When U is aligned with the z-axis, apply the original rotation, Φ, about the z-axis.

5. Apply the inverses of the transformations in reverse order.

Page 19: ©Larry F. Hodges (modified by Amos Johnson) 1 3-D Mathematical Preliminaries & Transformations

©Larry F. Hodges(modified by Amos Johnson)

19

A Rotation Φ About an Arbitrary Axis

[T-1][Ry(ß)][Rx(-µ)][RRzz((Φ)][)][Rx(µ)][Ry(-ß)][T][P]

Note:

P = 3D Point

T-1 = opposite translate from T [ ] = matrix