GithubHelp home page GithubHelp logo

rbpoly2tri's Introduction

Synopsis

These are Ruby 1.9.2+ bindings to poly2tri. It produces very nice triangulated meshes out of pretty arbitrary polygons.

This release contains an a (slightly-modified) version of Revision 31c314fae1 of the poly2tri C++ branch. Both poly2tri and rbpoly2tri are available under BSD/MIT-style permissive licenses. See poly2tri/LICENSE and LICENSE for details.

poly2tri Homepage

To install via RubyGems:

gem install rbpoly2tri

To install from repo:

gem build rbpoly2tri.gemspec
gem install rbpoly2tri-<version>.gem

Simple Usage:

require 'rbpoly2tri'

# The initial input must be simple (non-intersecting, no holes), and
# repeated vertices are not allowed.  Holes may be added later.

inp = [[100.0, 0.0], [0.0, 0.0], [0.0, 47.85714326530613],
       [-4.999999, 50.0], [0.0, 50.0], [0.0, 100.0], [100.0, 100.0],
       [100.0, 50.0], [200.0, 50.0], [100.0, 5.0]]

# CDT.  You know, Constrained Delaunay Triangulation.
tess = Poly2Tri::CDT.new(inp)

# if you're in the mood to add a hole to this polygon, now's the time:
tess.add_hole [[10, 10], [10,30], [30, 30], [30,10]]

tess.triangulate!
triangles = tess.triangles # => A huge amount of vertices, man.

See Also:

  • If you're into this type of thing, you might want to check out rbclipper, my bindings to Clipper, a polygon clipping library.

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.