#### Archived

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.

## 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 on other sites
Hi,
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

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 23
• 9
• 49
• ### Forum Statistics

• Total Topics
632639
• Total Posts
3007586
• ### Who's Online (See full list)

There are no registered users currently online

×