how to get collision point on unit sphere

Started by
5 comments, last by heron3d 14 years, 1 month ago
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
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.
would this qualify as an iterative algorithm?
Quote:Original post by heron3d
would this qualify as an iterative algorithm?


No.
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?
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.
lol, you are absolutely right. let me try to really understand your equation. Thanks again!

This topic is closed to new replies.

Advertisement