开发者

how to subtract circle from an arbitrary polygon

开发者 https://www.devze.com 2022-12-29 22:50 出处:网络
Given an arbitary polygon with vertices stored in either clockwise/counterclockwise fashion (depicted as a black rectangle in the diagram), I need to be able to subtract an arbitrary number of circles

Given an arbitary polygon with vertices stored in either clockwise/counterclockwise fashion (depicted as a black rectangle in the diagram), I need to be able to subtract an arbitrary number of circles (in red on the diagram) from that polygon. Removing a circle could possibly split the polygon 开发者_JS百科into two seperate polygons (as depicted by the second line in the diagram).

I'm not sure where to start.

Example http://www.freeimagehosting.net/uploads/89a0276d9d.jpg


Warning: getting code to do this absolutely right is tricky. (Conceptually it's fine, but you can quickly get bogged down in numerical errors and edge cases.) You're basically asking for a 2D version of Constructive Solid Geometry. You might want to see if you can use an existing library written by an expert in computational geometry. There are some libraries here that will probably do what you want, but you'll have to choose a representation that suits you best and convert what you have into that representation.


Here's a freeware polygon clipping library (written in Delphi and C++) that does what you're asking: http://sourceforge.net/projects/polyclipping/

0

精彩评论

暂无评论...
验证码 换一张
取 消