Sign in to follow this  

Distance from curve

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

The curve is parameterized as (x(t),y(t)) = (t,t^3). The point of interest is (x0,y0). You need a point (x(t),y(t)) so that the vector (x(t)-x0,y(t)-y0) is perpendicular to the curve at (x(t),y(t)). The tangent to the curve is (x'(t),y'(t)) = (1,3*t^2), so you need 0 = Dot((x'(t),y'(t)),(x(t)-x0,y(t)-y0)). This condition reduces to 0 = (t-x0) + 3*t^2*(t^3-y0), which is a degree 5 polynomial in t. Numerically solve the polynomial equation for t.

Share this post


Link to post
Share on other sites
I was basically going to say what Dave said before he ninja'd me to it, but you also need to be careful regarding that absolute value sign. What I would do is solve the polynomial for both x3 and -x3, and sort the solutions (by distance of course). Then return the first "good" solution, i.e. you have a solution where x is positive but it came from solving -x3 (which gives you a negative value), it doesn't satisfy |x|3 and you skip it.

Share this post


Link to post
Share on other sites
In regards to the absolute value, you can move it from the function to the point you're checking since you know the closest point on the polynomial will have the same x sign as the point you're comparing it to. So take the absolute value of X at the start and ignore it in the function and it should work out right.

Share this post


Link to post
Share on other sites

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