It's not exactly a high school subject, but for my senior year I convinced the math head to add in a new "independent computer science" course. I'm planning on making a simple FPS game using OpenGL throughout the semester, although during the summer I plan to do all of the research and theory for it.
Bassically, I need an algorithm to determine weather or not a line in 3D space, intersects with a sphere in 3d space. I'm using c++.
POINT point[3]; // Line point 1, Line point 2, Sphere center point
double radus; // Sphere Radius
point[0].x= ...
point[0].y= ...
point[0].z= ...
point[1].x= ...
point[1].y= ...
point[1].z= ...
point[2].x= ...
point[2].y= ...
point[2].z= ...
radius= ...
bool LineSphereCollision(POINT LineP1, POINT LineP2, POINT Center, double Radius)
{
//This is were I need help.
if (The line and sphere intersect)
return true;
else
return false;
}
My AP Calculus techer couldn't remember how to do it, and I've looked on google, didn't get exactly what I wanted on the first page so I quit and came here. =)
Please tell me if I made any basic coding mistakes also.
Bassically, I need an algorithm to determine weather or not a line in 3D space, intersects with a sphere in 3d space. I'm using c++.
POINT point[3]; // Line point 1, Line point 2, Sphere center point
double radus; // Sphere Radius
point[0].x= ...
point[0].y= ...
point[0].z= ...
point[1].x= ...
point[1].y= ...
point[1].z= ...
point[2].x= ...
point[2].y= ...
point[2].z= ...
radius= ...
bool LineSphereCollision(POINT LineP1, POINT LineP2, POINT Center, double Radius)
{
//This is were I need help.
if (The line and sphere intersect)
return true;
else
return false;
}
My AP Calculus techer couldn't remember how to do it, and I've looked on google, didn't get exactly what I wanted on the first page so I quit and came here. =)
Please tell me if I made any basic coding mistakes also.

Comment