Documentation ¶
Overview ¶
Package incrdelaunay implements a library for incremental Delaunay triangulation, with support for dynamically adding and removing points.
Index ¶
- func Voronoi(delaunay *Delaunay, polygon func([]FloatPoint), w, h int)
- type Circumcircle
- type CircumcircleGrid
- func (c *CircumcircleGrid) AddTriangle(t Triangle, index uint16)
- func (c CircumcircleGrid) HasPoint(p Point, triangles []Triangle) bool
- func (c CircumcircleGrid) IterCircumcirclesThatContain(p Point, triangles []Triangle, contains func(i uint16))
- func (c CircumcircleGrid) IterThatHasVertex(p Point, triangles []Triangle, contains func(i uint16))
- func (c CircumcircleGrid) RemoveCircumcirclesThatContain(p Point, triangles []Triangle, contains func(i uint16))
- func (c CircumcircleGrid) RemoveThatHasVertex(p Point, triangles []Triangle, contains func(i uint16))
- func (c *CircumcircleGrid) RemoveTriangle(tri Triangle, index uint16)
- func (c *CircumcircleGrid) Set(other *CircumcircleGrid)
- type Delaunay
- type Edge
- type FloatPoint
- type IVoronoi
- type Point
- type Triangle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Voronoi ¶ added in v1.1.7
func Voronoi(delaunay *Delaunay, polygon func([]FloatPoint), w, h int)
Types ¶
type Circumcircle ¶
type Circumcircle struct { Radius float32 // contains filtered or unexported fields }
Circumcircle represents a circumcircle of a Triangle.
type CircumcircleGrid ¶
type CircumcircleGrid struct {
// contains filtered or unexported fields
}
CircumcircleGrid is a data structure that uses spatial partitioning to allowed fast operations involving multiple Triangle's and their Circumcircle's.
func NewCircumcircleGrid ¶
func NewCircumcircleGrid(cols, rows, w, h int) CircumcircleGrid
NewCircumcircleGrid returns a new grid with a specified number of columns and rows.
func (*CircumcircleGrid) AddTriangle ¶
func (c *CircumcircleGrid) AddTriangle(t Triangle, index uint16)
AddTriangle adds a Triangle with an index to the grid.
func (CircumcircleGrid) HasPoint ¶
func (c CircumcircleGrid) HasPoint(p Point, triangles []Triangle) bool
HasPoint returns if a triangle in the grid has a point.
func (CircumcircleGrid) IterCircumcirclesThatContain ¶ added in v1.1.7
func (c CircumcircleGrid) IterCircumcirclesThatContain(p Point, triangles []Triangle, contains func(i uint16))
func (CircumcircleGrid) IterThatHasVertex ¶ added in v1.1.7
func (c CircumcircleGrid) IterThatHasVertex(p Point, triangles []Triangle, contains func(i uint16))
func (CircumcircleGrid) RemoveCircumcirclesThatContain ¶
func (c CircumcircleGrid) RemoveCircumcirclesThatContain(p Point, triangles []Triangle, contains func(i uint16))
RemoveCircumcirclesThatContain removes all triangles whose circumcircle contain a point.
func (CircumcircleGrid) RemoveThatHasVertex ¶
func (c CircumcircleGrid) RemoveThatHasVertex(p Point, triangles []Triangle, contains func(i uint16))
RemoveThatHasVertex removes all triangles that have a vertex.
func (*CircumcircleGrid) RemoveTriangle ¶
func (c *CircumcircleGrid) RemoveTriangle(tri Triangle, index uint16)
RemoveTriangle removes a triangle from the grid.
func (*CircumcircleGrid) Set ¶
func (c *CircumcircleGrid) Set(other *CircumcircleGrid)
Set sets a CircumcircleGrid to another CircumcircleGrid.
type Delaunay ¶
type Delaunay struct {
// contains filtered or unexported fields
}
Delaunay represents a Delaunay triangulation.
func NewDelaunay ¶
NewDelaunay returns a new Delaunay triangulation.
func (Delaunay) GetClosestTo ¶
GetClosestTo returns the closest point in the triangulation to point p.
func (*Delaunay) Insert ¶
Insert adds a point to the Delaunay triangulation using the Bowyer-Watson algorithm. Duplicate points are kept track of.
func (Delaunay) IterTriangles ¶
IterTriangles iterates through all the triangles in the triangulation, calling function triangle for each one.
func (Delaunay) NumPoints ¶
NumPoints returns the number of points in the triangulation, including duplicate points.
type FloatPoint ¶ added in v1.1.7
type FloatPoint struct {
X, Y float64
}
type IVoronoi ¶ added in v1.1.7
type IVoronoi struct {
// contains filtered or unexported fields
}
func NewVoronoi ¶ added in v1.1.7
func (*IVoronoi) IterPolygons ¶ added in v1.1.7
func (v *IVoronoi) IterPolygons(polygon func([]FloatPoint))
type Point ¶
type Point struct {
X, Y int16
}
Point represents a 2D point, using int16 to optimize space.
type Triangle ¶
type Triangle struct {
A, B, C Point
Circumcircle Circumcircle
}
Triangle stores the vertices of a triangle as well as its circumcircle.
func NewSuperTriangle ¶
NewSuperTriangle returns a Triangle large enough to cover all points within (0, 0) to (w, h).
func NewTriangle ¶
NewTriangle return a new Triangle and calculates its circumcircle given three points.