Documentation ¶
Index ¶
- func CalcEllipseSegmentCount[T constraints.Float](r, e T) int
- type Contour
- type Contour32
- type Contour64
- type Polygon
- func (p Polygon[T]) Bounds() geom.Rect[T]
- func (p Polygon[T]) ClipLine(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) Clone() Polygon[T]
- func (p Polygon[T]) Contains(pt geom.Point[T]) bool
- func (p Polygon[T]) ContainsEvenOdd(pt geom.Point[T]) bool
- func (p Polygon[T]) Intersect(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) Simplify() Polygon[T]
- func (p Polygon[T]) Subtract(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) Union(other Polygon[T]) Polygon[T]
- func (p Polygon[T]) Xor(other Polygon[T]) Polygon[T]
- type Polygon32
- type Polygon64
- type Segment
- type Segment32
- type Segment64
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.
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
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]) ContainsEvenOdd ¶
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 ¶
Intersect returns the intersection of both polygons. Does not handle self-intersecting polygons. Use Simplify() first, if necessary.
func (Polygon[T]) Simplify ¶
Simplify creates a new Polygon without self-intersections or repeated edges.
func (Polygon[T]) Subtract ¶
Subtract returns the result of removing the other polygon from this polygon. Does not handle self-intersecting polygons. Use Simplify() first, if necessary.
type Segment ¶ added in v1.89.0
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
CoincidesWith returns true if the segment matches the given start and end in either direction.