# distance from hermite curve

## Recommended Posts

Bobboau    122
I'm tinkering with making a 2d platformer engine, I'd like to make the level out of Hermite splines, but I need a way to do collision detection, I don't need anything complex like spline on spline intersections, I just want a function for finding the point on the curve that is closest to an arbitrary point. I know calculus, so I know the standard method for doing this; take the line function make a distance function, take the derivative, wherever the derivative is 0 will be a (the) closest point. problem is in the last step I end up with something unwieldy and I can't solve the 0s. I'm hoping there is a standard solution for this. I'm defining the Hermite curve as: (start_pnt * 2.0f*t3 - 3.0f*t2 + 1.0f) + (end_pnt * -2.0f*t3 + 3.0f*t2) + (start_tan * t3 - 2.0f*t2 + t) + (end_tan * -t3 + t2) any help would be appreciated

##### Share on other sites
kauna    2922

Have you considered converting your hermite curve in a set of lines and use them for the collision test?

Just an idea which may save lots of headache.

Best regards!

##### Share on other sites
Bobboau    122
that's my backup plan. it seems like colliding with the curve should be faster and more accurate, not to mention smoother.

##### Share on other sites
Bobboau    122
just found [url=http://www.tinaja.com/glib/cmindist.pdf]this[/url] looks like I'm not the only person to try and fail at this, but this looks like I might get some good results.