- Forum
- General C++ Programming
- Ray sphere intersection

I would need to create a ray sphere intersection in C++. Kindly help me with creating a sphere first then do a ray sphere intersection.

Sruthi04 (1) I would need to create a ray sphere intersection in C++. Kindly help me with creating a sphere first then do a ray sphere intersection. |

a sphere is simply x*x+y*y + z*z - r*r = 0

that is the surface, so an inequality gives you the volume if you need all the points inside it too.

if a ray intersects it, then, the equation of the ray (3d line, read this and pick a way to handle it https://math.stackexchange.com/questions/404440/what-is-the-equation-for-a-3d-line) is going to be equal to the above (for the same x,y, and z in both equations).

if there is no solution, they do not intersect.

Topic archived. No new replies allowed.