Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Sphere/Ray intersection?

This topic is 6671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone tell me the math involved with finding the point on a sphere where a ray intersects it? Its easy enough with a tessalated sphere (plane/ray intersection) but I''m trying to find the exact point. Anyone?

Share this post

Link to post
Share on other sites
I hope I''m not mistaken, but here is what I think of your problem:

Lets''s say we have the sphere (xs,ys,zs) -center , r- radius
A point on the sphere (x,y,z) is defined by :
(x-xs)^2 + (y-ys)^2 + (z-zs)^2 = r^2 (1)

Now the ray should have a start point (x0,y0,z0) and a vector (xv,yv,zv)
A point on the ray (x,y,z) is defined by :
(x-x0) (y-y0) (z-z0)
----- = ------ = ------ (2)
xv yv zv

now, take a point on the ray with an arbitrary x and find y and z for it using the 2nd equation. Put them in the 1st equation and you should have a 2nd degree equation that you can solve to find the x of the intersection. Using (2) you now have y and z.
Hope this does it for you. Horia

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!