poly

package
v1.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2021 License: MPL-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Epsilon = float64Epsilon

Epsilon controls how close a point has to be to be considered the same as another. If performance becomes an issue, you can increase this value, which will cause more points to merge together, reducing the amount of work that must be done. Don't raise it too high, though, as it can distort the resulting polygon.

Functions

func CalcEllipseSegmentCount added in v1.20.0

func CalcEllipseSegmentCount(r, e float64) int

CalcEllipseSegmentCount returns a suggested number of segments to use when generating an ellipse. 'r' is the largest radius of the ellipse. 'e' is the acceptable error, typically 1 or less.

Types

type Contour

type Contour []geom.Point

Contour is a sequence of vertices connected by line segments, forming a closed shape.

func (Contour) Bounds

func (c Contour) Bounds() geom.Rect

Bounds returns the bounding rectangle of a contour.

func (Contour) Clone

func (c Contour) Clone() Contour

Clone returns a copy of this contour.

func (Contour) Contains

func (c Contour) Contains(pt geom.Point) bool

Contains returns true if the point is contained by the contour.

type Polygon

type Polygon []Contour

Polygon holds one or more contour lines. The polygon may contain holes and may be self-intersecting.

func ApproximateEllipse added in v1.16.0

func ApproximateEllipse(bounds geom.Rect, sections int) Polygon

ApproximateEllipse creates a polygon that approximates an ellipse. 'sections' indicates how many segments to break the ellipse contour into.

func ApproximateEllipseAuto added in v1.20.0

func ApproximateEllipseAuto(bounds geom.Rect) Polygon

ApproximateEllipseAuto creates a polygon that approximates an ellipse, automatically choose the number of segments to break the ellipse contour into. This uses CalcEllipseSegmentCount() with an 'e' of 0.2.

func Rect added in v1.16.0

func Rect(bounds geom.Rect) Polygon

Rect creates a new polygon in the shape of a rectangle.

func (Polygon) Bounds

func (p Polygon) Bounds() geom.Rect

Bounds returns the bounding rectangle of this polygon.

func (Polygon) Clone

func (p Polygon) Clone() Polygon

Clone returns a duplicate of this polygon.

func (Polygon) Contains

func (p Polygon) Contains(pt geom.Point) bool

Contains returns true if the point is contained by the polygon.

func (Polygon) ContainsEvenOdd

func (p Polygon) ContainsEvenOdd(pt geom.Point) bool

ContainsEvenOdd returns true if the point is contained by the polygon using the even-odd rule. https://en.wikipedia.org/wiki/Even-odd_rule

func (Polygon) Intersect

func (p Polygon) Intersect(other Polygon) Polygon

Intersect returns the intersection of both polygons.

func (Polygon) Subtract

func (p Polygon) Subtract(other Polygon) Polygon

Subtract returns the result of removing the other polygon from this polygon.

func (Polygon) Union

func (p Polygon) Union(other Polygon) Polygon

Union returns the union of both polygons.

func (Polygon) Xor

func (p Polygon) Xor(other Polygon) Polygon

Xor returns the result of xor'ing this polygon with the other polygon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL