All Projects → akavel → Polyclip Go

akavel / Polyclip Go

Go library for Boolean operations on 2D polygons.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Polyclip Go

EsriRESTScraper
A Python class that scrapes ESRI Rest Endpoints and exports data to a geodatabase
Stars: ✭ 43 (-38.57%)
Mutual labels:  geometry, polygon
ludigraphix.github.io
Documentation for Ludigraphix
Stars: ✭ 21 (-70%)
Mutual labels:  geometry, polygon
martinez-src
Mirrored implementations of polygon clipping/CSG/operations algorithm, in C (original, by Martínez et al) and ActionScript3 (port, by Mahir Iqbal)
Stars: ✭ 34 (-51.43%)
Mutual labels:  geometry, polygon
Shape-Your-Music
A web application for drawing music.
Stars: ✭ 106 (+51.43%)
Mutual labels:  geometry, polygon
Phidl
Python GDS layout and CAD geometry creation
Stars: ✭ 56 (-20%)
Mutual labels:  polygon, geometry
osm-static-maps
Openstreetmap static maps is a nodejs lib, CLI and server open source inspired on google static map service
Stars: ✭ 130 (+85.71%)
Mutual labels:  geometry, polygon
polygon-splitter
A small (<10kb minified) javascript library for splitting polygons by a polyline.
Stars: ✭ 20 (-71.43%)
Mutual labels:  geometry, polygon
Matgeom
Matlab geometry toolbox for 2D/3D geometric computing
Stars: ✭ 168 (+140%)
Mutual labels:  polygon, geometry
Wicket
A modest library for moving between Well-Known Text (WKT) and various framework geometries
Stars: ✭ 484 (+591.43%)
Mutual labels:  polygon, geometry
Earcut.hpp
Fast, header-only polygon triangulation
Stars: ✭ 447 (+538.57%)
Mutual labels:  polygon, geometry
Geokit
Geo-Toolkit for PHP.
Stars: ✭ 223 (+218.57%)
Mutual labels:  polygon, geometry
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-48.57%)
Mutual labels:  polygon, geometry
Cgal
The public CGAL repository, see the README below
Stars: ✭ 2,825 (+3935.71%)
Mutual labels:  polygon, geometry
envelope ex
Utilities for calculating and comparing envelopes from geometries
Stars: ✭ 15 (-78.57%)
Mutual labels:  geometry, polygon
Unity.library.eppz.geometry
2D Geometry for Unity. Suited for everyday polygon hassle. Polygon clipping, polygon winding direction, polygon area, polygon centroid, centroid of multiple polygons, line intersection, point-line distance, segment intersection, polygon-point containment, polygon triangulation, polygon Voronoi diagram, polygon offset, polygon outline, polygon buffer, polygon union, polygon substraction, polygon boolean operations, and more. It is a polygon fest.
Stars: ✭ 198 (+182.86%)
Mutual labels:  polygon, geometry
geofeatures2
A lightweight, high performance geometry library in Swift.
Stars: ✭ 18 (-74.29%)
Mutual labels:  geometry, polygon
Plexus
Polygonal mesh processing.
Stars: ✭ 90 (+28.57%)
Mutual labels:  polygon, geometry
Polylidar
Polylidar3D - Fast polygon extraction from 3D Data
Stars: ✭ 106 (+51.43%)
Mutual labels:  polygon, geometry
SharpMath2
2D math / geometry collision library for C#, compatable with monogame.
Stars: ✭ 36 (-48.57%)
Mutual labels:  geometry, polygon
Wxdraw
几何画图(微信小程序)
Stars: ✭ 36 (-48.57%)
Mutual labels:  polygon, geometry

WARNING

The library is KNOWN TO HAVE BUGS!!! Unfortunately, currently I don't have resources to investigate them thoroughly enough and in timely fashion. In case somebody is interested in taking ownership of the library, I'm open to ceding it. That said, the issues totally haunt me and occasionally I stubbornly try to come back to them and pick the fight up again. In particular:

  • #3 was confirmed to be an omission in the original paper/algorithm. As far as I understand, it surfaces when one of the polygons used has self-overlapping edges (e.g. when an edge (0,0)-(1,1) is used twice in the same polygon). I believe it should be possible to fix, but it requires thorough analysis of the algorithm and good testing. One attempt I made at a fix which seemed OK initially was later found to break the library even more and thus I reverted it.
  • #8 was reported recently and I haven't yet had time to even start investigating it.

About

Build Status on Travis-CI. License: MIT. Documentation on godoc.org.

Library polyclip-go is a pure Go, MIT-licensed implementation of an [algorithm for Boolean operations on 2D polygons] fmartin (invented by F. Martínez, A.J. Rueda, F.R. Feito) -- that is, for calculation of polygon intersection, union, difference and xor.

The original paper describes the algorithm as performing in time O((n+k) log n), where n is number of all edges of all polygons in operation, and k is number of intersections of all polygon edges.

Example

Simplest Go program using polyclip-go for calculating intersection of a square and triangle:

// example.go
package main

import (
    "fmt"
    "github.com/akavel/polyclip-go" // or: bitbucket.org/...
)

func main() {
    subject := polyclip.Polygon{{{1, 1}, {1, 2}, {2, 2}, {2, 1}}} // small square
    clipping := polyclip.Polygon{{{0, 0}, {0, 3}, {3, 0}}}        // overlapping triangle
    result := subject.Construct(polyclip.INTERSECTION, clipping)

    // will print triangle: [[{1 1} {1 2} {2 1}]]
    fmt.Println(result)
}

To compile and run the program above, execute the usual sequence of commands:

go get github.com/akavel/polyclip-go  # or: bitbucket.org/...
go build example.go
./example      # Windows: example.exe

For full package documentation, run locally godoc github.com/akavel/polyclip-go, or visit online documentation for polyclip-go.

See also

  • Online docs for polyclip-go.
  • Microsite about the original algorithm, from its authors (with PDF, and public-domain code in C++).
  • The as3polyclip library -- a MIT-licensed ActionScript3 library implementing this same algorithm (it actually served as a base for polyclip-go). The page also contains some thoughts with regards to speed of the algorithm.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].