Documentation ¶
Overview ¶
Package poly provides types and functions for working with polygons in support of the pathfind package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFloats ¶
ParseFloats parses a slice of float32s from a comma-separated string of numbers, for example "186.5,364.7,303.25,374,303.1,412". Spaces are ignored.
Types ¶
type Line ¶
type Line struct {
Seg LineSeg
}
Line represents a straight line that goes through the two points of a line segment and continues to infinity in both directions.
type LineSeg ¶
A LineSeg represents a line segment between two points A and B.
func (LineSeg) ClosestPt ¶
ClosestPt returns the point on the line segment l that is closest to point p. This is either the orthogonal projection of p onto l or one of l's end points if the projection is not within the line segment.
func (LineSeg) Crosses ¶
Crosses returns true if line segments l and m cross each other, otherwise false.
type Polygon ¶
A Polygon is a polygon in 2-dimensional space, represented as a slice of its vertices.
func ParsePolygon ¶
ParsePolygon parses a new polygon from a comma-separated coordinate string, for example "186.5,364.7,303.25,374,303.1,412". Should have an even number of coordinate values. Rest is ignored.
func (Polygon) ClosestPt ¶
ClosestPt returns the closest point to point pt on the outline of polygon p.
func (Polygon) IsConcaveAt ¶
IsConcaveAt checks, whether the vertex with index i of polygon p is concave or not.
func (Polygon) IsCrossedBy ¶
IsCrossedBy checks if any side of polygon p is crossed by line segment ls.
type PolygonSet ¶
type PolygonSet []Polygon
A PolygonSet represents multiple polygons.
func ParsePolygons ¶
func ParsePolygons(coords []string) PolygonSet
ParsePolygons parses polygons from n comma-separated coordinate strings and returns them as a PolygonSet. See ParsePolygon for details on the format.