Chapter 4,

 <  Day Day Up  >  

Chapter 4, "Vector Operations"

Vector Versus Scalar

Scalar = magnitude only.

Vector = magnitude + direction.

Displacement

Displacement = final position “ initial position.

D x = x f x i

Polar Coordinates

Vector

graphics/ap01inl30.gif

where graphics/ap01inl06.gif is the magnitude of A and q is the direction.

Cartesian Coordinates (Components)

Vector graphics/ap01inl19.gif

where graphics/ap01inl07.gif is one unit in the x direction and graphics/ap01inl08.gif is one unit in the y direction.

Converting from Polar to Cartesian Coordinates

For vector graphics/ap01inl30.gif ,

graphics/ap01equ49.gif

where a 1 = graphics/ap01inl06.gif cos q and a 2 = graphics/ap01inl06.gif sin q .

Converting from Cartesian to Polar Coordinates

For vector graphics/ap01inl19.gif ,

graphics/ap01equ09.gif

.

Cartesian Coordinates (Components) in 3D

Vector graphics/ap01equ46.gif

where graphics/ap01inl07.gif is one unit in the x direction, graphics/ap01inl08.gif is one unit in the y direction, and graphics/ap01inl09.gif is one unit in the z direction.

Commutative Law of Vector Addition

A + B = B + A

for any vectors A and B.

Adding 2D Vectors Numerically

graphics/ap01equ50.gif

for vectors graphics/ap01inl29.gif and graphics/ap01inl26.gif .

Adding 3D Vectors Numerically

graphics/ap01equ51.gif

for vectors graphics/ap01inl27.gif and graphics/ap01inl28.gif .

Subtracting Vectors Numerically

graphics/ap01equ52.gif

for vectors graphics/ap01inl29.gif and graphics/ap01inl26.gif .

Subtracting 3D Vectors Numerically

graphics/ap01equ53.gif

for vectors graphics/ap01inl23.gif and graphics/ap01inl24.gif .

Scalar Multiplication in Polar Coordinates

graphics/ap01equ47.gif

for any scalar c and vector graphics/ap01inl30.gif .

Scalar Multiplication in Cartesian Coordinates

graphics/ap01equ54.gif

for any scalar c and vector graphics/ap01inl25.gif .

Normalizing a 2D Vector

graphics/ap01equ10.gif

for any vector A = [ a 1 a 2 ].

Normalizing a 3D Vector

graphics/ap01equ11.gif

for any vector A = [ a 1 a 2 a 3 ].

Dot Product in 2D

A B = a 1 b 1 + a 2 b 2

for any 2D vectors A = [ a 1 a 2 ] and B = [ b 1 b 2 ].

Dot Product in 3D

A B = a 1 b 1 + a 2 b 2 + a 3 b 3

for any 3D vectors A = [ a 1 a 2 a 3 ] and B = [ b 1 b 2 b 3 ].

Perpendicular Check

If A B = 0, A B.

Positive or Negative Dot Product

If A B < 0 (negative), q > 90 °

If A B > 0 (positive), q < 90 °

where q is the angle between vectors A and B.

Angle Between Two Vectors

graphics/ap01equ12.gif

where q is the angle between vectors A and B.

Cross-Product

A x B = [( a 2 b 3 a 3 b 2 ) ( a 3 b 1 a 1 b 3 ) ( a 1 b 2 a 2 b 1 )]

for any two vectors A = [ a 1 a 2 a 3 ] and B = [ b 1 b 2 b 3 ].

Perpendicular Vectors

A x B is perpendicular to both vectors A and B.

Cross-Product Is Not Commutative

A x B B x A

In fact, A x B = “(B x A) for any two 3D vectors A and B.

Surface Normal

Surface normal = graphics/ap01equ48.gif

for any two 3D vectors A and B.

Angle Between Two Vectors

graphics/ap01equ14.gif

for any two 3D vectors A and B.

 <  Day Day Up  >  


Beginning Math and Physics for Game Programmers
Beginning Math and Physics for Game Programmers
ISBN: 0735713901
EAN: 2147483647
Year: 2004
Pages: 143
Authors: Wendy Stahler

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net