# how to get collision point on unit sphere

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

## Recommended Posts

Hi, I have a unit sphere, velocity and an external point. How can I get the point at which the point exits the sphere? This is a diagram of the problem

##### Share on other sites
You trace a ray
R(t) = P + t*V

Your sphere is formed by the points that are at a distance r from C. in other words, you are looking for a time t such that R(t) is at a distance r from C.

dist(R(t),C) = r <=> dist(R(t),C)^2 = r^2
dist(R(t),C)^2 = dot_product(R(t)-C,R(t)-C)
= dot_product(P + t*V - C, P + t*V - C)
= dot_product((P-C) + t*V, (P-C) + t*V)
= dot_product(P-C,P-C) + 2*t*dot_product(P-C,V) + t^2*dot_product(V,V)

The equation of setting that last quantity to r^2 is a second-degree equation on t. The three dot products can be computed from the data you have. The smaller solution (negative square root) is when ray enters the sphere, and the larger one (positive square root) is when it exists. Now that you have the time, substitute in R(t) = P + t*V.

##### Share on other sites
would this qualify as an iterative algorithm?

##### Share on other sites
Quote:
 Original post by heron3dwould this qualify as an iterative algorithm?

No.

##### Share on other sites
hey Alvaro,
Thanks for your reply. I'm trying to understand it as best I can. Your use of the word time has thrown me off a little. Can you explain?

##### Share on other sites
Think of the ray as a moving point that starts at P and advances V every second. At any given time `t' the point will be at P + t*V. This is just a way to think about the parameter t that helps me visualize the situation.

If you ignore the use of the word "time", the Math still makes sense.

EDIT: Now that I think about it, your use of the word "exits" also implies some notion of time.

##### Share on other sites
lol, you are absolutely right. let me try to really understand your equation. Thanks again!

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 12
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632929
• Total Posts
3009284
• ### Who's Online (See full list)

There are no registered users currently online

×