I need some help with a formula or bit of code for finding the distance to the closest point in a line segment. Effectively, the “distance from the line segment” is going to be used as a sort of “bonding box”, so that a user can click relatively close to a line, and it count as clicking on that line.
Share
If you’re using Swing, then you should be able to use
Line2D.ptSegDist(Point2D)or its various overloads to do all the math for you.