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
(more about physics)

I just did this the other day. Take a normal vector perpendicular to the line (away from circle) and multiply by the radius of the circle. Add to the circle’s coordinates, check to see if it crosses the line.

You have to use sqrt to normalize the perp vector but maybe that’s unavoidable.

<rad> could you please elaborate. I thoughtt hta you couldnt normalise a vector of a line. Thought that you needed to have more than 2 points to normalise.

Normalizing is just dividing by vector length:
sqrt(x^2+y^2), sqrt(x^2+y^2+z^2), etc.
The number of dimensions doesn’t matter when finding the length of a vector.