Line clipping to arbitary 2D polygon

后端 未结 2 1686
梦毁少年i
梦毁少年i 2021-01-12 13:44

If I get a line segment which was long enough to cross a given polygon, which could be concave or convex polygon. How did I find the all the intersected light segments which

2条回答
  •  一向
    一向 (楼主)
    2021-01-12 14:05

    There really isn't a simple solution to your problem, especially with curves (beziers and splines). On top of the complexities of polygon clipping, there's the considerable challenge of reconstructing the clipped curves (assuming you want the clipping result to remain as beziers and splines and not just 'flattened' line approximations).

    I have recently released a beta update* to my polygon clipping library 'Clipper' that does do line-polygon and line-line clipping (where lines can be curves too). However, while the main library is written in Delphi, C++ & C#, the new beta code is so far only in Delphi which may not help you. Nevertheless if you look at the code you'll see why I state there's no 'simple' solution.

    • Edit 15 Jul 2011: This 'update' never got beyond this beta release and is now simply 'proof-of-concept'. It is now based on an old version of my Clipper library and would need a major rewrite to be maintainable and extensible. (At some stage I may revisit it but I'm currently intent on further improving the core library.) Nevertheless, this 'proof-of-concept' Delphi code can be downloaded here

    Clipper demo image

提交回复
热议问题