Jump to content
  • Advertisement
Sign in to follow this  
Axiverse

Closest point on a polygon

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

I'm looking for a way to compute the closest point on a polygon to any point. This would be used many times, so I'm looking for some way to preprocess the polygon so that the search time can be reduced.

Share this post


Link to post
Share on other sites
Advertisement
You can build the Voronoi regions corresponding to the edges of the polygon. Look at the related topic of "medial axes".

Share this post


Link to post
Share on other sites
Quote:
Original post by smitty1276
Are you assuming the point to lie on the plane of the polygon?


I am. The important question is whether the OP has this constraint in mind. If the problem is in 3D and the point is not necessarily on the plane of the polygon, the approach is nearly the same.

Share this post


Link to post
Share on other sites
Yeah, this is meant to be used in 2d space. It seems that constructing a voronoi may be more work that it's worth. I'm currently using an algorithem that searches outwards from the point in a box manner, which is giving better performance than brute force. I don't know if there's any alternatives.

Share this post


Link to post
Share on other sites
An alternative might be to do a series of closest-point-on-line-segment tests for each edge of the polygon and choose the closest point out of all the tests, and possibly precompute a bunch of information required for each test. But I haven't actually implemented any of these methods to know which one would be fastest.

Share this post


Link to post
Share on other sites
Quote:
Original post by Axiverse
Yeah, this is meant to be used in 2d space. It seems that constructing a voronoi may be more work that it's worth. I'm currently using an algorithem that searches outwards from the point in a box manner, which is giving better performance than brute force. I don't know if there's any alternatives.


Are your polygons convex?

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!