Sign in to follow this  

how to get collision point on unit sphere

This topic is 2848 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

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 [IMG]http://i45.tinypic.com/ajwmqr.jpg[/IMG]

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

This topic is 2848 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this