poly

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MPL-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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. Note that the methods Union, Intersect, Subtract, Xor, and ClipLine all require that the polygons not have have self-intersections. Use of the Simplify() method will ensure a polygon can be used with those methods.

func (*Polygon) Add

func (p *Polygon) Add(c Contour)

Add a contour to a polygon.

func (Polygon) Bounds

func (p Polygon) Bounds() geom.Rect

Bounds returns the bounding rectangle of this polygon.

func (Polygon) ClipLine

func (p Polygon) ClipLine(other Polygon) Polygon

ClipLine returns the result of removing the other polygon from this polygon. Assumes this polygon is actually a line.

Note: This function is not designed to handle self-intersecting polygons. Remove self-intersections first using the Simplify function.

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.

Note: This function is not designed to handle self-intersecting polygons. Remove self-intersections first using the Simplify function.

func (Polygon) Simplify

func (p Polygon) Simplify() Polygon

Simplify returns a polygon with all self-intersections and repeated edges removed.

func (Polygon) Subtract

func (p Polygon) Subtract(other Polygon) Polygon

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

Note: This function is not designed to handle self-intersecting polygons. Remove self-intersections first using the Simplify function.

func (Polygon) Union

func (p Polygon) Union(other Polygon) Polygon

Union returns the union of both polygons.

Note: This function is not designed to handle self-intersecting polygons. Remove self-intersections first using the Simplify function.

func (Polygon) Xor

func (p Polygon) Xor(other Polygon) Polygon

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

Note: This function is not designed to handle self-intersecting polygons. Remove self-intersections first using the Simplify function.

Jump to

Keyboard shortcuts

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