Sei sulla pagina 1di 14

Basics

Points
y y1 P1 x1 x

three numbers suffice but specify where you measure from!

O z1 z

Directions
y y1 P1 x1 P2

From P1 towards P2
v x
P1 ( x1 , y1 , z1 ), P2 ( x2 , y 2 , z 2 ) vector v = ( x2 x1 , y 2 y1 , z 2 z1 ) length l = ( x2 x1 ) 2 + ( y2 y1 ) 2 + ( z 2 z1 ) 2 normalized vector ( x2 x1 y 2 y1 z 2 z1 , , ) l l l
3

O z1 z

Vector operations
Dot product
result is a scalar (one number) cosine of the angle between the vectors times the product of the lengths of the vectors if unit length vectors, dot product is cosine of angle between the two directions commutative

( x1 , y1 , z1 ) ( x2 , y2 , z 2 ) = x1 x2 + y1 y2 + z1 z2 ( x1 , y1 , z1 ) ( x2 , y2 , z 2 ) = x1 + y1 + z1
2 2 2

x2 + y2 + z2 cos 4
2 2 2

Vector operations
Cross-product
result is a vector
perpendicular to both operands length is lengths times sine of angle

v1 x v2

normal of operands plane not commutative

v2 x v1 v1

v2

( x1 , y1 , z1 ) ( x2 , y2 , z 2 ) = ( y1 z 2 z1 y2 , z1 x2 x1 z 2 , x1 y2 y1 x2 ) v1 v2 = v1 v2 sin v1 v2 = v2 v1
5

Geometry

Line
y y1 P1 x1 P2

P1 ( x1 , y1 , z1 ), P2 ( x2 , y 2 , z 2 ) line P = P1 + ( P2 P1 )t t ( , ) segment P = P1 + ( P2 P1 )t t [0,1]


7

O z1 z

Planes (point and normal)


y n

P0 O z x

P0 ( x0 , y0 , z0 ), n( n x , n y , n z ) plane n x ( x x0 ) + n y ( y y 0 ) + n z ( z z 0 ) = 0 ( P P0 )n = 0

Planes (3 points)
y P0 P1 O z n
P0 ( x0 , y0 , z0 ), P1 ( x1 , y1 , z1 ), P0 ( x2 , y 2 , z 2 )

P2 x

normal n = ( P1 P0 ) ( P2 P0 ) plane ( P P0 )n = 0

Normal direction given by enumeration order

Triangles (3 points)
y P0 P1 O z n
P0 ( x0 , y0 , z0 ), P ( x1 , y1 , z1 ), P2 ( x2 , y2 , z2 ) 1 normal n = ( P P0 ) ( P2 P0 ) 1

P2 x

plane ( P P0 )n = 0 triangle ( P P0 )n = 0 Sidedness( P, P , P ) = Sidedness( P , P , P ) 0 1 2 0 1 1 1 Sidedness( P, P , P2 ) = Sidedness( P0 , P , P2 ) Sidedness ( P, P2 , P0 ) = Sidedness ( P , P2 , P0 ) 1

10

Transformations

11

Translations
Points
P1(x1, y1, z1) moves to P2(x2, y2, z2) translation amount (x2-x1, y2-y1, z2-z1)

Vectors are invariant to translations


up means up no matter where you are

Segments and triangles are translated by translating their defining points

12

Rotations
y y1 = y2 P O z2 z1 z
13

Rotation about y axis

x1 x2

x2 = x1 cos + z1 sin y2 = y1 z 2 = x1 sin + z1 cos

Positive rotations
Convention
in right-handed coordinate systems look down axis to rotate about (towards origin) counterclockwise rotation transforms one positive axis into the other
y >0 z O x
14

Rotations
y y1 = y2 P O z2 z1 z P x1 x2 x

Rotation about y axis


rotation by positive amount rotation of point P rotation of vector OP segments and triangles are rotated by rotating points

x2 = x1 cos + z1 sin y2 = y1 z 2 = x1 sin + z1 cos


15

Matrix notation
Rotation about y axis
cos 0 sin 0 sin x1 x1 cos + z1 sin 1 0 y1 = y1 z1 x1 sin + z1 cos 0 cos

16

Scaling
y P1 P2 O P2 x P1

Example of scaling a segment

x1 ' = x1s x , y1 ' = y1s y , z1 ' = z1s z


z

x2 ' = x2 s x , y 2 ' = y 2 s y , z 2 ' = z 2 s z


17

Combinations of xforms
A chain of transformations
matrices are multiplied matrix multiplication is associative matrix multiplication is NOT commutative equivalent matrix

X 1 X 2 ... X n P = P' ( X 1 X 2 ... X n ) P = P' X P = P'


18

Combinations of xforms
r11 r 21 r31 0
2

r12 r22 r32 0


2

r13 r23 r33 0

t14 t 24 t34 1
2

Rigid body
any combination of rotations and translations R (r11, , r33) is orthographic
columns (and lines) are mutually perpendicular unit vectors

r11 + r21 + r31 = 1 r12 + r22 + r32 = 1


2 2 2

r13 + r23 + r33 = 1


2 2 2

(r11 , r21 , r31 ) (r12 , r22 , r32 ) = 0 (r12 , r22 , r32 ) (r13 , r23 , r33 ) = 0 (r13 , r23 , r33 ) (r11 , r21 , r31 ) = 0

preserves lengths and angles


19

Combinations of xforms
Affine transform
r11 r 21 r31 0 r12 r22 r32 0 r13 t14 r23 t 24 r33 t34 0 1
any combination of rotations, translations and scalings does not preserve angles and lengths does preserve parallelism of lines
20

10

Change of coordinate system


y

Given
y O z x O x P point P(x, y,z) new coordinate system
unit vectors x, y, z origin O

Find P (coordinates of point P in new coordinate system)

21

Change of coordinate system


y

First translate to new origin


y O z O x P, Pt x

Pt = P O'

22

11

Change of coordinate system


y y

Then rotate old axes into new axes


Pt , P O z z x x compute components of vector OP along new axes

x' x P ' = y'x z'x

x' y y' y z' y

x' z xt y ' z yt z ' z zt


23

Change of coordinate system


y

y O z

P, P

x' x P = y'x z 'x


'

x' y y' y z' y

x' z x O' x y ' z y O' y z ' z z O' z

x O x

24

12

Rotation about an arbitrary axis


Given
axis with origin Oa and direction a point P, angle

Rotate P degrees about the axis (Oa, a)


compute Pr which is the rotated point P

25

Step 1
Create new coordinate system with origin Oa and a as one of its axes
using axis x(1, 0, 0) set b = (x x a); normalize b set c = a x b; normalize c (Oa, a, b, c) is a new coordinate system
note: one needs to make sure that the auxiliary axis (in this case x) is not aligned with a; one solution is to consider x and y and pick the one that has the smaller dot product with a (ignoring the sign) since that axis is closer to being perpendicular to a.
26

13

Steps 2-4
Step 2: Transform P to the new coordinate system, P->P Step 3: Rotate about a (first axis), P->P Step 4: Transform back to original coordinate system, P->Pr

27

14

Potrebbero piacerti anche