Documentation
¶
Overview ¶
Package geometry provides a geometry coordinate system and attendant functions for dealing with grids.
Index ¶
- Constants
- func DirectionWord(direction int) string
- func Distance(a Point, b Point) float64
- func InSlice(c Point, target []Point) bool
- func NearestPointIndex(p Point, coords []Point) int
- func OppositeDirection(original int) int
- func PointInTriangle(pt Point, t Triangle) bool
- func RandomDirection() int
- type Circle
- type Edge
- type Grid
- type Point
- func Centroid(points []Point) Point
- func Circumcenter(triangle Triangle) Point
- func GenerateRandomPoints(height int, width int, number int) []Point
- func GenerateRandomPointsByDimensions(height int, width int, density float64) []Point
- func GetUniquePoints(points []Point) []Point
- func RandomPoint(height int, width int) Point
- func RemoveClumps(points []Point, distance float64) []Point
- func RemovePoints(pointsToRemove []Point, target []Point) []Point
- func SortPointsByDistance(source []Point) []Point
- type Polygon
- type Triangle
- type TriangleMesh
Constants ¶
const EAST = 2
const NORTH = 0
const NORTHEAST = 1
const NORTHWEST = 7
const SOUTH = 4
const SOUTHEAST = 3
const SOUTHWEST = 5
const WEST = 6
Variables ¶
This section is empty.
Functions ¶
func DirectionWord ¶
DirectionWord returns the string description of a direction
func NearestPointIndex ¶
NearestPointIndex finds the index in a slice of points of the nearest point to the given one
func OppositeDirection ¶
OppositeDirection returns the opposite of a given compass direction
func PointInTriangle ¶
PointInTriangle determines if the given point is in the given triangle
func RandomDirection ¶
func RandomDirection() int
RandomDirection returns a random compass direction
Types ¶
type Circle ¶
Circle is a circle
func Circumcircle ¶
Circumcircle calculates the circumcircle for a given triangle
type Edge ¶
Edge is an undirected line
func GetUniqueEdges ¶
GetUniqueEdges returns all the unique edges in a slice
func (Edge) IsSharedByTriangles ¶
IsEdgeSharedByTriangles checks to see if the given edge is shared by any of the triangles in the given slice
type Point ¶
Point is an x, y location
func Centroid ¶
Centroid returns a point that is in the center of a polygon defined by the given points
func Circumcenter ¶
Circumcenter finds the circumcenter for a given triangle
func GenerateRandomPoints ¶
GenerateRandomPoints generates a set of random points inside the given height and width according to the number given
func GenerateRandomPointsByDimensions ¶
GenerateRandomPointsByDimensions generates a set of random points of the given height, width, and density. Density is a floating point number between 0 and 1.
func GetUniquePoints ¶
GetUniquePoints returns only unique points from a slice of points
func RandomPoint ¶
RandomPoint returns a random point in the given height and width
func RemoveClumps ¶
RemoveClumps removes all points from a given set of points that are closer than N distance
func RemovePoints ¶
RemovePoints returns a slice of points with a set removed
func SortPointsByDistance ¶
SortPointsByDistance sorts points by distance
type Polygon ¶
Polygon is a polygon
func PolygonFromPoints ¶
PolygonFromPoints returns a polygon built from the given slice of points
type Triangle ¶
Triangle is a triangle
func SuperTriangle ¶
SuperTriangle returns a triangle big enough to contain all of the given points
func TriangleFromPoints ¶
TriangleFromPoints returns a triangle based on a set of points
func (Triangle) RemoveFrom ¶
RemoveFrom removes a triangle from a slice of triangles
type TriangleMesh ¶
type TriangleMesh struct { Triangles []Triangle Nodes []Point // the centroids of each triangle Vertices []Point Edges []Edge }
TriangleMesh is a mesh of triangles
func BowyerWatson ¶
func BowyerWatson(points []Point) TriangleMesh
BowyerWatson returns a Delaunay triangulation of the given points using the Bowyer-Watson algorithm.