shape

package
v0.0.0-...-9c88ebf Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PointsInContainer

func PointsInContainer(pts []d2.Pt, c Container, filter bool, buf []d2.Pt) []d2.Pt

PointsInContainer checks the given points against the container. If the contains value matches filter, it is appended to the buffer.

Types

type Area

type Area interface {
	Area() float64
	SignedArea() float64
}

Area of a shape, signed area may take procession into account. For instance, a triangle with points defined proceeding counter-clockwise wil have a positive area and proceeding clockwise will have a negative area.

type BoundingBoxer

type BoundingBoxer interface {
	BoundingBox() (min, max d2.Pt)
}

BoundingBoxer returns the corners of a bounding box.

type Centroid

type Centroid interface {
	Centroid() d2.Pt
}

Centroid is the center of mass of a shape.

type Closest

type Closest interface {
	Closest(pt d2.Pt) d2.Pt
}

Closest point on the perimeter to given point.

type Container

type Container interface {
	Contains(d2.Pt) bool
}

Container checks if a shape contains a point.

type ConvexHuller

type ConvexHuller interface {
	ConvexHull() []d2.Pt
}

ConvexHuller returns a slice of points that form a convex hull that contains the underlying geometric object.

type Intersection

type Intersection [2]Shape

Intersection takes two Shapes and creates a new Shape that is their intersection.

func (Intersection) Contains

func (a Intersection) Contains(pt d2.Pt) bool

Contains returns true if the point is inside both shapes.

func (Intersection) ConvexHull

func (a Intersection) ConvexHull() []d2.Pt

ConvexHull fulfills shape.ConvexHuller. It returns the convex hull of the Intersection. If the underlying Convex hulls are tight, the result will also be tight.

func (Intersection) LineIntersections

func (a Intersection) LineIntersections(l line.Line, buf []float64) []float64

LineIntersections fulfills line.Intersector returning the intesection points on the perimeter of the Intersection of the shapes.

type Perimeter

type Perimeter interface {
	Perimeter() float64
}

Perimeter length of the shape

type Shape

type Shape interface {
	Container
	line.Intersector
	ConvexHuller
}

Shape is an interface that is easy to implement for most primitives but allows for complex generic shape functions.

type Subtract

type Subtract [2]Shape

Subtract defines a shape by subtracting the second shape from the first.

func (Subtract) Contains

func (s Subtract) Contains(pt d2.Pt) bool

Contains returns true if the point is inside the first shape but not the second.

func (Subtract) ConvexHull

func (s Subtract) ConvexHull() []d2.Pt

ConvexHull fulfills shape.ConvexHuller. It returns the convex hull of the Intersection. It just returns the convex hull of the shape being subtracted from, so the result may not be tight.

func (Subtract) LineIntersections

func (s Subtract) LineIntersections(l line.Line, buf []float64) []float64

LineIntersections fulfills line.LineIntersector returning the intesection points on the perimeter of the Subtraction of the shapes.

type Union

type Union [2]Shape

func (Union) Contains

func (a Union) Contains(pt d2.Pt) bool

func (Union) ConvexHull

func (a Union) ConvexHull() []d2.Pt

ConvexHull fulfills shape.ConvexHuller. It returns the convex hull of the Intersection. If the underlying Convex hulls are tight, the result will also be tight.

func (Union) LineIntersections

func (a Union) LineIntersections(l line.Line, buf []float64) []float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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