# Collision detection and Lines

Whats the easiest way to see when an animated line has crossed into the radius oif a sphere, i assume thats how you detect a collision. My guess is i get the distance between the current point oon the line, cX,cY,cZ and the init points of the sphere, iX,iY,iZ.

so:
dX = iX - cX;
dY = iY - cY;
dZ = iZ - cZ;

Then i guess i check to see if the distance (dX,dY,dZ) is in fact less than the sun radius.

Is this right or wrong? Can someone point me in the direction to where i might find more information on this. Like the actual maths, e.g. do i need rto use vecters and normals, and what are they.

Cheers Guys vbery much appreciated

This seem correct to detect if you cross the sphere. It is probably the simplest way to do collision detection.

You should find more interesting stuff in the ‘Math and algo’ opengl forum.

There are interesting tutorials at NeHe :
http://nehe.gamedev.net/data/articles/article.asp?article=10
http://nehe.gamedev.net/lesson.asp?index=06
(collision detection at the bottom)
http://nehe.gamedev.net/lesson.asp?index=08