poly

package
v1.96.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MPL-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcEllipseSegmentCount added in v1.20.0

func CalcEllipseSegmentCount[T constraints.Float](r, e T) 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[T constraints.Float] []geom.Point[T]

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

func (Contour[T]) Bounds

func (c Contour[T]) Bounds() geom.Rect[T]

Bounds returns the bounding rectangle of a contour.

func (Contour[T]) Clone

func (c Contour[T]) Clone() Contour[T]

Clone returns a copy of this contour.

func (Contour[T]) Contains

func (c Contour[T]) Contains(pt geom.Point[T]) bool

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

type Contour32 added in v1.92.0

type Contour32 = Contour[float32]

Contour32 is an alias for the float32 version of Contour.

type Contour64 added in v1.92.0

type Contour64 = Contour[float64]

Contour64 is an alias for the float64 version of Contour.

type Polygon

type Polygon[T constraints.Float] []Contour[T]

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[T constraints.Float](bounds geom.Rect[T], sections int) Polygon[T]

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[T constraints.Float](bounds geom.Rect[T]) Polygon[T]

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[T constraints.Float](bounds geom.Rect[T]) Polygon[T]

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

func (Polygon[T]) Bounds

func (p Polygon[T]) Bounds() geom.Rect[T]

Bounds returns the bounding rectangle of this polygon.

func (Polygon[T]) ClipLine

func (p Polygon[T]) ClipLine(other Polygon[T]) Polygon[T]

ClipLine assumes p is actually a line and clips it.

func (Polygon[T]) Clone

func (p Polygon[T]) Clone() Polygon[T]

Clone returns a duplicate of this polygon.

func (Polygon[T]) Contains

func (p Polygon[T]) Contains(pt geom.Point[T]) bool

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

func (Polygon[T]) ContainsEvenOdd

func (p Polygon[T]) ContainsEvenOdd(pt geom.Point[T]) 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[T]) Intersect

func (p Polygon[T]) Intersect(other Polygon[T]) Polygon[T]

Intersect returns the intersection of both polygons. Does not handle self-intersecting polygons. Use Simplify() first, if necessary.

func (Polygon[T]) Simplify

func (p Polygon[T]) Simplify() Polygon[T]

Simplify creates a new Polygon without self-intersections or repeated edges.

func (Polygon[T]) Subtract

func (p Polygon[T]) Subtract(other Polygon[T]) Polygon[T]

Subtract returns the result of removing the other polygon from this polygon. Does not handle self-intersecting polygons. Use Simplify() first, if necessary.

func (Polygon[T]) Union

func (p Polygon[T]) Union(other Polygon[T]) Polygon[T]

Union returns the union of both polygons. Does not handle self-intersecting polygons. Use Simplify() first, if necessary.

func (Polygon[T]) Xor

func (p Polygon[T]) Xor(other Polygon[T]) Polygon[T]

Xor returns the result of xor'ing this polygon with the other polygon. Does not handle self-intersecting polygons. Use Simplify() first, if necessary.

type Polygon32 added in v1.92.0

type Polygon32 = Polygon[float32]

Polygon32 is an alias for the float32 version of Polygon.

type Polygon64 added in v1.92.0

type Polygon64 = Polygon[float64]

Polygon64 is an alias for the float64 version of Polygon.

type Segment added in v1.89.0

type Segment[T constraints.Float] struct {
	Start geom.Point[T]
	End   geom.Point[T]
}

Segment holds the start and end point of a single segment within a contour of a polygon.

func (Segment[T]) CoincidesWith added in v1.89.0

func (s Segment[T]) CoincidesWith(start, end geom.Point[T]) bool

CoincidesWith returns true if the segment matches the given start and end in either direction.

func (Segment[T]) FindIntersection added in v1.89.0

func (s Segment[T]) FindIntersection(other Segment[T], tryBothDirections bool) (count int, pi0, pi1 geom.Point[T])

FindIntersection finds the points where the two segments intersect, if any.

type Segment32 added in v1.93.0

type Segment32 = Segment[float32]

Segment32 is an alias for the float32 version of Segment.

type Segment64 added in v1.93.0

type Segment64 = Segment[float64]

Segment64 is an alias for the float64 version of Segment.

Jump to

Keyboard shortcuts

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