Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How can I check it if a line3D/ or ray is intersecting a sphere?

share|improve this question

3 Answers 3

The real time rendering web-site is good source for different intersection algorithms (including ray/sphere intersection):

http://www.realtimerendering.com/intersections.html

share|improve this answer

The problem logically reduces to finding the shortest distance between the ray (line) and the sphere centre. If that distance is shorter than the sphere radius, there is an intersection.

Of course, there's a formula for line-point distance.

share|improve this answer

It is a part of ray tracer design. Look at the ray and sphere intersection. It is very simple and commonly used in every ray tracer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.