triangolatte alternatives and similar packages
Based on the "Science and Data Analysis" category.
Alternatively, view triangolatte alternatives based on common mentions on social networks and blogs.
-
gonum
Gonum is a set of numeric libraries for the Go programming language. It contains libraries for matrices, statistics, optimization, and more. -
gonum/plot
gonum/plot provides an API for building and drawing plots in Go. -
Stats
A statistics package with common functions that are missing from the Golang standard library. -
gosl
Go scientific library for linear algebra, FFT, geometry, NURBS, numerical methods, probabilities, optimisation, differential equations, and more. -
streamtools
general purpose, graphical tool for dealing with streams of data. -
chart
Simple Chart Plotting library for Go. Supports many graphs types. -
goraph
A pure Go graph theory library(data structure, algorith visualization) -
dataframe-go
Dataframes for machine-learning and statistics (similar to pandas). -
gonum/mat64
The general purpose package for matrix computation. Package mat64 provides basic linear algebra operations for float64 matrices. -
calendarheatmap
Calendar heatmap in plain Go inspired by Github contribution activity. -
TextRank
TextRank implementation in Golang with extendable features (summarization, weighting, phrase extraction) and multithreading (goroutine) support. -
sparse
Go Sparse matrix formats for linear algebra supporting scientific and machine learning applications, compatible with gonum matrix libraries. -
vectormath
Vectormath for Go, an adaptation of the scalar C functions from Sony's Vector Math library, as found in the Bullet-2.79 source code. (currently inactive) -
PiHex
Implementation of the "Bailey-Borwein-Plouffe" algorithm for the hexadecimal number Pi -
ode
An ordinary differential equation (ODE) solver which supports extended states and channel-based iteration stop conditions. -
GoStats
GoStats is an Open Source GoLang library for math statistics mostly used in Machine Learning domains, it covers most of the Statistical measures functions. -
gofrac
A (goinstallable) fractions library for go with support for basic arithmetic. -
assocentity
Package assocentity returns the average distance from words to a given entity. -
go-fn
Mathematical functions written in Go language, that are not covered by math pkg -
rootfinding
root-finding algorithms library for finding roots of quadratic functions. -
bradleyterry
Provides a Bradley-Terry Model for pairwise comparisons. -
gocomplex
A complex number library for the Go programming language. -
mudlark-go
A collection of packages providing (hopefully) useful code for use in software using Google's Go programming language.
Scout APM - Leading-edge performance monitoring starting at $39/month
Do you think we are missing an alternative of triangolatte or a related project?
README
triangolatte
2D triangulation library. Allows translating lines and polygons (both based on points) to the language of GPUs.
Features normal and miter joint line triangulation. Handles polygons using ear clipping algorithm with hole elimination included.
[screenshot](assets/examples_screenshot.png)
For reference: triangulates 99.76% of 75 thousand buildings in Cracow under 3.43s on average programmer notebook (single threaded).
Table of contents
Installation
Nothing surprising
go get github.com/tchayen/triangolatte
Usage
Basic example
vertices := []Point{{10, 20}, {30, 40}, {50, 60}}
t, err = triangolatte.Polygon(vertices)
Examples
In /examples
you can find:
- buildings – full-blown WebGL previewer of buildings triangulated in city example
- city – triangulation of whole city downloaded from Open Street Map
- gpx – GPX format parsing and triangulation of its data
- wireframe – desktop OpenGL wireframe previewer for triangulated shapes
You will find instructions for running the code there.
Features
API
Polygon(points []Point, holes [][]Point) ([]float64, error)
Takes array of points and produces array of triangle coordinates.
Based on the following paper and inspired by EarCut.
JoinHoles(points [][]Point) ([]Point, error)
Removes holes, joining them with the rest of the polygon. Provides preprocessing
for Polygon
. First element of the points array is the outer polygon, the rest
of them are considered as holes to be removed.
Line(joint Joint, points []Point, width int) ([]float64, error)
Takes array of points and triangulates them to resemble a line of given width. Returns array of two-coordinate CCW triangles one after another.
Types
To select method of joining line segments.
type Joint int
const (
// No joint correction.
Normal Joint = 0
// Producing miter joints, i.e. extending the lines until they meet at some point.
Miter Joint = 1
)
For calculations using points.
type Point struct {
X, Y float64
}
A wrapper for Point used in cyclic list.
type Element struct {
Prev, Next *Element
Point Point
}
Helpers
You can have a look at helpers.go
file. It stores triangolatte's helper
functions used mostly by tests and examples. They are not exported because I
don't want to commit to supporting them in the future, but they might turn out
useful for you.
Tests
Code is (more or less) covered in tests. You can run them like this:
go test -v
You can also run benchmarks for selected functions (refer to the *_test.go
files for availability). For example:
go test -run NONE -bench IsInsideTriangle
Benchmarks
NOTE: This section contains work in progress. Numbers below are better reference point than nothing, but still far from perfect.
Polygon()
on shape with 10 vertices takes 754ns
on average.
Triangulation of 75 thousand buildings runs for around 3.43s
.
Using average programmer's notebook. Expect speed up on faster CPUs or while splitting execution into separate threads.
Flame Graphs
CPU time % usage snaphost using Flame Graphs:
[assets/torch.svg](assets/torch.svg)
Want to learn what is it or maybe you are willing to generate one yourself? Check [FlameGraphs](flame_graphs.md) document in this repository.
Future plans
Optimizations
NOTE: this library is developed mostly with map data triangulation in mind and it will be its main performance target.
- explore possibilities for optimizations in
JoinHoles(...)
- maybe allow reusing point array for massive allocation reduction
Content
- provide more examples (e.g. desktop OpenGL usage, mobile app, live rendering pipeline, other unusual use cases...)
- add benchmarks with comparison to libraries in other languages
WebAssembly
One of the core plans for this library's development is creating, as soon as it becomes possible, some kind of WebAssembly module for use in JS.
Contributing
You are welcome to create an issue or pull request if you've got an idea what to do. It is usually a good idea to visit Gitter and discuss your thoughts.
Don't have one, but still want to contribute? Get in touch with us and we can brainstorm some ideas.
License
MIT License – refer to the [LICENSE](LICENSE) file.
*Note that all licence references and agreements mentioned in the triangolatte README section above
are relevant to that project's source code only.