Giter Club home page Giter Club logo

polypartition's Introduction

PolyPartition

PolyPartition is a lightweight C++ library for polygon partition and triangulation. PolyPartition implements multiple algorithms for both convex partitioning and triangulation. Different algorithms produce different quality of results (and their complexity varies accordingly). The implemented methods/algorithms with their advantages and disadvantages are outlined below.

For input parameters and return values see method declarations in polypartition.h. All methods require that the input polygons are not self-intersecting, are defined in the correct vertex order (counter-clockwise for non-holes, clockwise for holes), and any holes must be explicitly marked as holes (you can use SetHole(true)). Polygon vertices can easily be ordered correctly by calling TPPLPoly::SetOrientation method.

Input polygon:

images/test_input.png

Triangulation by ear clipping

Method: TPPLPartition::Triangulate_EC

Time/Space complexity: O(n^2)/O(n)

Supports holes: Yes, by calling TPPLPartition::RemoveHoles.

Quality of solution: Satisfactory in most cases.

Example:

images/tri_ec.png

Optimal triangulation in terms of edge length using dynamic programming algorithm

Method: TPPLPartition::Triangulate_OPT

Time/Space complexity: O(n^3)/O(n^2)

Supports holes: No. You could call TPPLPartition::RemoveHoles prior to calling TPPLPartition::Triangulate_OPT, but the solution would no longer be optimal, thus defeating the purpose.

Quality of solution: Optimal in terms of minimal edge length.

Example:

images/tri_opt.png

Triangulation by partition into monotone polygons

Method: TPPLPartition::Triangulate_MONO

Time/Space complexity: O(n*log(n))/O(n)

Supports holes: Yes, by design

Quality of solution: Poor. Many thin triangles are created in most cases.

Example:

images/tri_mono.png

Convex partition using Hertel-Mehlhorn algorithm

Method: TPPLPartition::ConvexPartition_HM

Time/Space complexity: O(n^2)/O(n)

Supports holes: Yes, by calling TPPLPartition::RemoveHoles.

Quality of solution: At most four times the minimum number of convex polygons is created. However, in practice it works much better than that and often gives optimal partition.

Example:

images/conv_hm.png

Optimal convex partition using dynamic programming algorithm by Keil and Snoeyink

Method: TPPLPartition::ConvexPartition_OPT

Time/Space complexity: O(n^3)/O(n^3)

Supports holes: No. You could call TPPLPartition::RemoveHoles prior to calling TPPLPartition::Triangulate_OPT, but the solution would no longer be optimal, thus defeating the purpose.

Quality of solution: Optimal. A minimum number of convex polygons is produced.

Example:

images/conv_opt.png

polypartition's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.