Beginning Math and Physics for Game Programmers

 <  Day Day Up  >  

Chapter 2, "Geometry Snippets"

Pythagorean Theorem

In a right triangle, the square of the length c of the hypotenuse is equal to the sum of the squares of the lengths a and b of the other two sides: c 2 = a 2 + b 2 .

Distance Formula in 2D

where P 1 ( x 1 , y 1 ) and P 2 ( x 2 , y 2 ) are points on the line.

Distance Formula in 3D

where P 1 ( x 1 , y 1 , z 1 ) and P 2 ( x 2 , y 2 , z 2 ) are points on the line.

Midpoint Formula in 2D

is the midpoint between P 1 ( x 1 , y 1 ) and P 2 ( x 2 , y 2 ).

Midpoint Formula in 3D

is the midpoint between P 1 ( x 1 , y 1 , z 1 ) and P 2 ( x 2 , y 2 , z 2 ).

Parabola with a Vertical Axis

y = a ( x “ h ) 2 + k , with vertex ( h , k ) and axis of symmetry x = h .

Parabola with a Horizontal Axis

x = a ( y “ k ) 2 + h , with vertex ( h , k ) and axis of symmetry y = k .

Equation of a Circle

( x “ h ) 2 + ( y “ k ) 2 = r 2

where the center is ( h , k ) and the radius is r .

Equation of a Circle Centered at the Origin

x 2 + y 2 = r 2

where the center is (0,0) and the radius is r .

Equation of a Sphere

( x “ h ) 2 + ( y “ k ) 2 + ( z “ l ) 2 = r 2

where the center is ( h , k , l ) and the radius is r .

Equation of a Sphere Centered at the Origin

x 2 + y 2 + z 2 = r 2

where the center is (0,0,0) and the radius is r .

Circle-Circle Collision Detection

Given two circles and , if , a collision occurs.

Optimized Circle-Circle Collision Detection

Given two circles and , if ( h 2 “ h 1 ) 2 + ( k 2 “ k 1 ) 2 ( r 1 + r 2 ) 2 , a collision occurs.

Optimized Sphere-Sphere Collision Detection

Given two spheres and , if ( h 2 “ h 1 ) 2 + ( k 2 “ k 1 ) 2 + ( l 2 “ i 1 ) 2 ( r 1 + r 2 ) 2 , a collision occurs.

 <  Day Day Up  >  

Категории