Changes

Jump to: navigation, search

10th Floor/programming

652 bytes added, 16:32, 8 October 2010
sphere collision
=Collision=
*Sphere to Sphere collision
**Each sphere is described by an x and y co-ordinate located in the very center, as well as a radius.
**If the distance between each sphere is less than the sum of their radius's, then a collision has occurred.
'''Sphere to Sphere Collision '''
<pre style="display: inline-block;">
int collision_sphere (x_sphere1, y_sphere1, r_sphere1, x_sphere2, y_sphere2, r_sphere2){
int collision = 0;
double distance = √(x_sphere1 - x_sphere2)² + (y_sphere1 - y_sphere2)²; // calculate distance
if ((r_sphere1 + r_sphere2) > distance){ // compare to sum of radius
collsion = 1;
}
return collsion;
}
</pre>

Navigation menu