Jump to content
  • Advertisement
Sign in to follow this  
heron3d

how to get collision point on unit sphere

This topic is 3061 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 ajwmqr.jpg

Share this post


Link to post
Share on other sites
Advertisement
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
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 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
Sign in to follow this  

  • 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!