its easy to find out if a point is in a sphere but if something is very fast,how can i know if it hits the target???

is there an acurate and easy way to do it ?

# Collisions (I need help!)

Not really OpenGL related but i hope your programming some cool game in GL

How I would do this -

Get your first position obj1 = 1x,1y

Get your second position obj2 = 2x,2y

Now if your object has passed right through the first ie obj1 moves a larger distance than the size of obj2. You need to check the positions in between pos1 and pos2. Assuming the obj2 is stationary no other checks should be needed. if not stationary then you perform the check against both objects positions.

example stationary object:

x1,y1 = 10,10

y2,y2 = 20,20

you may want to check also these collision points

x1,y1

x1+1,y1+1

x1+2,y1+2

…

…

x1+9,y1+9

x2,y2

depending on how accurate you want your collision you divide your two positions by a number 1 to n and then check each of the resulting coords against collision bounds. The above example uses a subdivision of 10,

it would also check the start and end positions.

Hope this helps.

You could also calculate the number of subdivisions by dividing the distance between the movement points by the radius of your bounding sphere:

(pnt(x2,y2,z2)-pnt(x1,y1,z1)) / r

This gives you always the right number of subdivisions.

[This message has been edited by Kilam Malik (edited 07-19-2000).]