Documentation
¶
Overview ¶
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Package geom has geometry related structs and funcs.
Index ¶
- func AngleFromTriangleSideLengths(a, b, c float64) float64
- func BezLength(p0, p1, p2, p3 *Point, count float64) float64
- func CircleOnCircle(x0, y0, r0, x1, y1, r1 float64) bool
- func CircleToLine(x0, y0, x1, y1, cx, cy, r float64) (*Point, *Point, bool)
- func Clockwise(p1, p2, p3 *Point) bool
- func LineOnLine(x0, y0, x1, y1, x2, y2, x3, y3 float64) (float64, float64, bool)
- func PointDistanceToLine(px, py, x0, y0, x1, y1 float64) float64
- func PointDistanceToSegment(px, py, x0, y0, x1, y1 float64) float64
- func PointInCircle(x, y, cx, cy, cr float64) bool
- func PointInPolygon(x, y float64, points []float64) bool
- func PointInRect(x, y, rx, ry, rw, rh float64) bool
- func PolyInnerRadius(radius float64, sides int) float64
- func RectOnRect(x0, y0, w0, h0, x1, y1, w1, h1 float64) bool
- func SegmentOnLine(x0, y0, x1, y1, x2, y2, x3, y3 float64) (float64, float64, bool)
- func SegmentOnRect(x0, y0, x1, y1, rx, ry, rw, rh float64) bool
- func SegmentOnSegment(x0, y0, x1, y1, x2, y2, x3, y3 float64) (float64, float64, bool)
- type BezierCurve
- func (b *BezierCurve) GetPath() PointList
- func (b *BezierCurve) GetSegmentCount() int
- func (b *BezierCurve) LerpPoint(t float64) *Point
- func (b *BezierCurve) LinearPoints(count int) PointList
- func (b *BezierCurve) Point(t float64) *Point
- func (b *BezierCurve) SetSegmentCount(count int)
- func (b *BezierCurve) SlopeAtBezierT(t float64) float64
- func (b *BezierCurve) SlopeAtLinearT(t float64) float64
- type Circle
- func CircleThroughPointsWithArcHeight(x0, y0, x1, y1, height float64) (*Circle, error)
- func CircleTouchingCircle(c0 *Circle, angle, radius float64) *Circle
- func CircleTouchingTwoCircles(c0, c1 *Circle, radius float64, clockwise bool) *Circle
- func NewCircle(x, y, r float64) *Circle
- func NewCircleFromPoint(center *Point, r float64) *Circle
- func NewCircleFromPoints(p0, p1, p2 *Point) *Circle
- func (c *Circle) Contains(p *Point) bool
- func (c *Circle) Hit(d *Circle) bool
- func (c *Circle) InnerCircles(count int, rotation float64) CircleList
- func (c *Circle) Intersection(c1 *Circle) (*Point, *Point, bool)
- func (c *Circle) InvertPoint(p *Point) *Point
- func (c *Circle) InvertXY(x, y float64) (float64, float64)
- func (c *Circle) OuterCircles(count int, rotation float64) CircleList
- func (c *Circle) RandomizePosition(amount float64)
- func (c *Circle) RandomizeRadius(amount float64)
- func (c *Circle) RandomizedPosition(amount float64) *Circle
- func (c *Circle) RandomizedRadius(amount float64) *Circle
- func (c *Circle) Rotate(angle float64)
- func (c *Circle) RotateFrom(x, y float64, angle float64)
- func (c *Circle) Rotated(angle float64) *Circle
- func (c *Circle) RotatedFrom(x, y, angle float64) *Circle
- func (c *Circle) Scale(scale float64)
- func (c *Circle) ScaleFrom(x, y, scale float64)
- func (c *Circle) ScaleLocal(scale float64)
- func (c *Circle) Scaled(scale float64) *Circle
- func (c *Circle) ScaledFrom(x, y, scale float64) *Circle
- func (c *Circle) ScaledLocal(scale float64) *Circle
- func (c *Circle) Translate(x float64, y float64)
- func (c *Circle) Translated(tx, ty float64) *Circle
- type CircleList
- func (c *CircleList) Add(circle *Circle)
- func (c *CircleList) AddXY(x, y, r float64)
- func (c *CircleList) RandomizePosition(amount float64)
- func (c *CircleList) RandomizeRadius(amount float64)
- func (c *CircleList) Rotate(angle float64)
- func (c *CircleList) RotateFrom(x, y float64, angle float64)
- func (c *CircleList) Scale(scale float64)
- func (c *CircleList) ScaleFrom(x, y, scale float64)
- func (c *CircleList) ScaleLocal(scale float64)
- func (c *CircleList) Translate(x, y float64)
- type Line
- func (l *Line) Angle() float64
- func (l *Line) ClosestPoint(p *Point) *Point
- func (l *Line) DistanceTo(p *Point) float64
- func (l *Line) HitLine(m *Line) (float64, float64, bool)
- func (l *Line) HitSegment(s *Segment) (float64, float64, bool)
- func (l *Line) Parallel(dist float64) *Line
- func (l *Line) Perpendicular(p *Point) *Line
- type Point
- func BezierPoint(t float64, p0 *Point, p1 *Point, p2 *Point, p3 *Point) *Point
- func Bisect(pA, pB, pC *Point, length float64) *Point
- func LerpPoint(t float64, p0, p1 *Point) *Point
- func MidPoint(p0, p1 *Point) *Point
- func NewPoint(x, y float64) *Point
- func QuadraticPoint(t float64, p0 *Point, p1 *Point, p2 *Point) *Point
- func RandomPointInCircle(x, y, r float64, dist bool) *Point
- func RandomPointInRect(x, y, w, h float64) *Point
- func RandomPointInTriangle(A, B, C *Point) *Point
- func (p *Point) Angle() float64
- func (p *Point) AngleBetween(p0, p1 *Point) float64
- func (p *Point) AngleTo(o *Point) float64
- func (p *Point) Clone() *Point
- func (p *Point) Coords() (float64, float64)
- func (p *Point) Distance(p1 *Point) float64
- func (p *Point) Equals(other *Point) bool
- func (p *Point) Magnitude() float64
- func (p *Point) Normalize()
- func (p *Point) Normalized() *Point
- func (p *Point) Randomize(rx, ry float64)
- func (p *Point) Randomized(rx, ry float64) *Point
- func (p *Point) Rotate(angle float64)
- func (p *Point) RotateFrom(x, y float64, angle float64)
- func (p *Point) Rotated(angle float64) *Point
- func (p *Point) RotatedFrom(x, y, angle float64) *Point
- func (p *Point) Scale(scaleX float64, scaleY float64)
- func (p *Point) ScaleFrom(x, y, scaleX float64, scaleY float64)
- func (p *Point) Scaled(scaleX float64, scaleY float64) *Point
- func (p *Point) ScaledFrom(x, y, scaleX, scaleY float64) *Point
- func (p *Point) Translate(x float64, y float64)
- func (p *Point) Translated(tx, ty float64) *Point
- func (p *Point) UniScale(scale float64)
- func (p *Point) UniScaleFrom(x, y, scale float64)
- func (p *Point) UniScaled(scale float64) *Point
- func (p *Point) UniScaledFrom(x, y, scale float64) *Point
- type PointList
- func ConvexHull(points PointList) PointList
- func LineOnRect(lineX1, lineY1, lineX2, lineY2, rectX, rectY, rectW, rectH float64) PointList
- func LinearBezierPoints(count int, p0, p1, p2, p3 *Point) PointList
- func NewPointList() PointList
- func PointGrid(x, y, w, h, xres, yres float64) PointList
- func PoissonDiskSampling(x, y, width, height, radius float64, tries int) PointList
- func RandomPointList(count int, x, y, w, h float64) PointList
- func (p *PointList) Add(point *Point)
- func (p *PointList) AddXY(x, y float64)
- func (p PointList) BoundingBox() *Rect
- func (p PointList) Center() *Point
- func (p PointList) Clone() PointList
- func (p *PointList) Cull(test func(*Point) bool)
- func (p PointList) Culled(test func(*Point) bool) PointList
- func (p PointList) First() *Point
- func (p *PointList) Fisheye(radius float64)
- func (p *PointList) FisheyeFromPoint(center *Point, radius float64)
- func (p *PointList) FisheyeFromXY(x, y, radius float64)
- func (p PointList) Get(index int) *Point
- func (p *PointList) Insert(index int, point *Point) error
- func (p PointList) Interpolate(t float64) *Point
- func (p PointList) Last() *Point
- func (p PointList) Length() float64
- func (p *PointList) Noisified(sx, sy, z, offset float64) PointList
- func (p *PointList) Noisify(sx, sy, z, offset float64)
- func (p *PointList) Normalize()
- func (p *PointList) Normalized() PointList
- func (p *PointList) Randomize(rx, ry float64)
- func (p *PointList) Randomized(rx, ry float64) PointList
- func (p *PointList) Rotate(angle float64)
- func (p *PointList) RotateFrom(x, y float64, angle float64)
- func (p *PointList) RotateLocal(angle float64)
- func (p *PointList) Rotated(angle float64) PointList
- func (p *PointList) RotatedFrom(x, y float64, angle float64) PointList
- func (p *PointList) Scale(sx, sy float64)
- func (p *PointList) ScaleFrom(x, y, sx, sy float64)
- func (p *PointList) ScaleLocal(sx, sy float64)
- func (p *PointList) Scaled(sx, sy float64) PointList
- func (p *PointList) ScaledFrom(x, y, sx, sy float64) PointList
- func (p PointList) SortDistFrom(x, y float64) PointList
- func (p PointList) SortXY() PointList
- func (p PointList) SortYX() PointList
- func (p *PointList) Split(test func(*Point) bool) PointList
- func (p *PointList) Translate(x, y float64)
- func (p *PointList) Translated(x, y float64) PointList
- func (p *PointList) UniScale(scale float64)
- func (p *PointList) UniScaleFrom(x, y, scale float64)
- func (p *PointList) UniScaleLocal(scale float64)
- func (p *PointList) UniScaled(scale float64) PointList
- func (p *PointList) UniScaledFrom(x, y, scale float64) PointList
- func (p PointList) Unique() PointList
- func (p PointList) Uniqued() PointList
- func (p *PointList) Vortex(radius float64)
- func (p *PointList) VortexFromPoint(center *Point, radius float64)
- func (p *PointList) VortexFromXY(x, y, radius float64)
- type Rect
- type Segment
- func (s *Segment) ClosestPoint(p *Point) *Point
- func (s *Segment) DistanceTo(p *Point) float64
- func (s *Segment) Equals(other *Segment) bool
- func (s *Segment) HitLine(l *Line) (float64, float64, bool)
- func (s *Segment) HitRect(r *Rect) bool
- func (s *Segment) HitSegment(z *Segment) (float64, float64, bool)
- func (s *Segment) Length() float64
- func (s *Segment) Parallel(dist float64) *Line
- func (s *Segment) Points() (*Point, *Point)
- func (s *Segment) Randomize(amount float64)
- func (s *Segment) Randomized(amount float64) *Segment
- func (s *Segment) Rotate(angle float64)
- func (s *Segment) RotateFrom(x, y, angle float64)
- func (s *Segment) RotateLocal(angle float64)
- func (s *Segment) Rotated(angle float64) *Segment
- func (s *Segment) RotatedFrom(x, y, angle float64) *Segment
- func (s *Segment) RotatedLocal(angle float64) *Segment
- func (s *Segment) Scale(sx, sy float64)
- func (s *Segment) ScaleFrom(x, y, sx, sy float64)
- func (s *Segment) ScaleLocal(sx, sy float64)
- func (s *Segment) Scaled(sx, sy float64) *Segment
- func (s *Segment) ScaledFrom(x, y, sx, sy float64) *Segment
- func (s *Segment) ScaledLocal(sx, sy float64) *Segment
- func (s *Segment) Translate(x, y float64)
- func (s *Segment) Translated(x, y float64) *Segment
- func (s *Segment) UniScale(scale float64)
- func (s *Segment) UniScaleFrom(x, y, scale float64)
- func (s *Segment) UniScaleLocal(scale float64)
- func (s *Segment) UniScaled(scale float64) *Segment
- func (s *Segment) UniScaledFrom(x, y, scale float64) *Segment
- func (s *Segment) UniScaledLocal(scale float64) *Segment
- type SegmentList
- func (s *SegmentList) Add(segment *Segment)
- func (s *SegmentList) AddXY(x0, y0, x1, y1 float64)
- func (s *SegmentList) Noisify(sx, sy, z, offset float64)
- func (s *SegmentList) Randomize(amount float64)
- func (s *SegmentList) Rotate(angle float64)
- func (s *SegmentList) RotateFrom(x, y float64, angle float64)
- func (s *SegmentList) RotateLocal(angle float64)
- func (s *SegmentList) Scale(sx, sy float64)
- func (s *SegmentList) ScaleFrom(x, y, sx, sy float64)
- func (s *SegmentList) ScaleLocal(sx, sy float64)
- func (s *SegmentList) Translate(x, y float64)
- func (s *SegmentList) UniScale(scale float64)
- func (s *SegmentList) UniScaleFrom(x, y, scale float64)
- func (s *SegmentList) UniScaleLocal(scale float64)
- type Triangle
- func EquilateralTriangleFromCenterAndPoint(c, p0 *Point) *Triangle
- func EquilateralTriangleFromTwoPoints(p0, p1 *Point, clockwise bool) *Triangle
- func IsoscoleseTriangle(point *Point, sideLength, angle float64) *Triangle
- func NewTriangle(x0, y0, x1, y1, x2, y2 float64) *Triangle
- func NewTriangleFromPoints(pA, pB, pC *Point) *Triangle
- func (t *Triangle) Altitude(index int) float64
- func (t *Triangle) AltitudeLine(index int) *Segment
- func (t *Triangle) Angles() []float64
- func (t *Triangle) Area() float64
- func (t *Triangle) BisectorLine(index int) *Segment
- func (t *Triangle) Centroid() *Point
- func (t *Triangle) CircumCenter() *Point
- func (t *Triangle) CircumCircle() *Circle
- func (t *Triangle) Contains(p *Point) bool
- func (t *Triangle) Edges() SegmentList
- func (t *Triangle) Equals(other *Triangle) bool
- func (t *Triangle) Foot(index int) *Point
- func (t *Triangle) InCenter() *Point
- func (t *Triangle) InCircle() *Circle
- func (t *Triangle) Lengths() []float64
- func (t *Triangle) MedianLine(index int) *Segment
- func (t *Triangle) OrthicTriangle() *Triangle
- func (t *Triangle) OrthoCenter() *Point
- func (t *Triangle) Points() PointList
- func (t *Triangle) Randomize(amount float64)
- func (t *Triangle) Randomized(amount float64) *Triangle
- func (t *Triangle) Rotate(angle float64)
- func (t *Triangle) RotateFrom(x, y, angle float64)
- func (t *Triangle) RotateLocal(angle float64)
- func (t *Triangle) Rotated(angle float64) *Triangle
- func (t *Triangle) RotatedFrom(x, y, angle float64) *Triangle
- func (t *Triangle) RotatedLocal(angle float64) *Triangle
- func (t *Triangle) Scale(sx, sy float64)
- func (t *Triangle) ScaleFrom(x, y, sx, sy float64)
- func (t *Triangle) ScaleLocal(sx, sy float64)
- func (t *Triangle) Scaled(sx, sy float64) *Triangle
- func (t *Triangle) ScaledFrom(x, y, sx, sy float64) *Triangle
- func (t *Triangle) ScaledLocal(sx, sy float64) *Triangle
- func (t *Triangle) String() string
- func (t *Triangle) Translate(x, y float64)
- func (t *Triangle) Translated(tx, ty float64) *Triangle
- func (t *Triangle) UniScale(scale float64)
- func (t *Triangle) UniScaleFrom(x, y, scale float64)
- func (t *Triangle) UniScaleLocal(scale float64)
- func (t *Triangle) UniScaled(scale float64) *Triangle
- func (t *Triangle) UniScaledFrom(x, y, scale float64) *Triangle
- func (t *Triangle) UniScaledLocal(scale float64) *Triangle
- type TriangleList
- func (t *TriangleList) Add(triangle *Triangle)
- func (t *TriangleList) Edges() SegmentList
- func (t *TriangleList) Randomize(amount float64)
- func (t *TriangleList) Rotate(angle float64)
- func (t *TriangleList) RotateFrom(x, y float64, angle float64)
- func (t *TriangleList) RotateLocal(angle float64)
- func (t *TriangleList) Scale(sx, sy float64)
- func (t *TriangleList) ScaleFrom(x, y, sx, sy float64)
- func (t *TriangleList) ScaleLocal(sx, sy float64)
- func (t *TriangleList) Translate(x, y float64)
- func (t *TriangleList) UniScale(scale float64)
- func (t *TriangleList) UniScaleFrom(x, y, scale float64)
- func (t *TriangleList) UniScaleLocal(scale float64)
- type Vector
- func (v *Vector) Abs() *Vector
- func (v *Vector) Add(w *Vector) *Vector
- func (v *Vector) Angle() float64
- func (v *Vector) AngleValueTo(w *Vector) float64
- func (v *Vector) CrossProduct(w *Vector) float64
- func (v *Vector) DotProduct(w *Vector) float64
- func (v *Vector) Magnitude() float64
- func (v *Vector) Max(other float64) *Vector
- func (v *Vector) Min(other float64) *Vector
- func (v *Vector) Norm() float64
- func (v *Vector) Normalized() *Vector
- func (v *Vector) Project(w *Vector) float64
- func (v *Vector) Scaled(factor float64) *Vector
- func (v *Vector) Subtract(w *Vector) *Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AngleFromTriangleSideLengths ¶
AngleFromTriangleSideLengths returns one angle of a triangle where the lengths of each side are known. It returns the angle between a and b.
func BezLength ¶
BezLength returns the length of a bezier curve. count is how many segments the curve will be sliced into. The higher the count, the more accurate. 1000 is a decent start.
func CircleOnCircle ¶
CircleOnCircle returns whether or not two circles intersect. TODO: return the points of intersection.
func CircleToLine ¶
CircleToLine reports the points of intersection between a line and a circle.
func LineOnLine ¶
LineOnLine returns whether or not two infinite length lines intersect and the point they intersect if they do.
func PointDistanceToLine ¶
PointDistanceToLine reports the distance from a point to a line.
func PointDistanceToSegment ¶
PointDistanceToSegment reports the distance from a point to a line segment
func PointInCircle ¶
PointInCircle returns whether or not a point is within a circle.
func PointInPolygon ¶
PointInPolygon returns whether or not a point is within a polygon.
func PointInRect ¶
PointInRect returns whether or not a point is within a rectangle.
func PolyInnerRadius ¶
PolyInnerRadius returns the radius of the largest circle that can fit inside the given regular polygon.
func RectOnRect ¶
RectOnRect returns whether or not two rectangles intersect. TODO: return the rect of intersection.
func SegmentOnLine ¶
SegmentOnLine returns whether or not a segment intersects an infinite length line and returns the point it intersects if it does. x0, y0 -> x1, y1 = segment. x2, y2 -> x3, y3 = line
func SegmentOnRect ¶
SegmentOnRect returns whether or not a segment intersects a rectangle. TODO: return the points of intersection.
Types ¶
type BezierCurve ¶
type BezierCurve struct {
P0, P1, P2, P3 *Point
// contains filtered or unexported fields
}
BezierCurve represents a Bezier curve. In addition to containing the control points of the curve, it precalculates a segmented path that represents the curve as a series of points. This can be used to linearly interpolate along the curve, to find points or the slope of the curve at those positions. Changing the segment count will recalculate the path.
func NewBezierCurve ¶
func NewBezierCurve(p0, p1, p2, p3 *Point) *BezierCurve
NewBezierCurve creates a new BezierCurve object.
func (*BezierCurve) GetPath ¶
func (b *BezierCurve) GetPath() PointList
GetPath returns the point list representing this path.
func (*BezierCurve) GetSegmentCount ¶
func (b *BezierCurve) GetSegmentCount() int
GetSegmentCount returns the current segment count.
func (*BezierCurve) LerpPoint ¶
func (b *BezierCurve) LerpPoint(t float64) *Point
LerpPoint returns a linearly interpolated point along the BezierCurve.
func (*BezierCurve) LinearPoints ¶
func (b *BezierCurve) LinearPoints(count int) PointList
LinearPoints creates a list of points roughly evenly distributed along the curve.
func (*BezierCurve) Point ¶
func (b *BezierCurve) Point(t float64) *Point
Point returns a point on the curve interpolated from t = 0.0 to 1.0.
func (*BezierCurve) SetSegmentCount ¶
func (b *BezierCurve) SetSegmentCount(count int)
SetSegmentCount sets the count of segments to use in a path of this curve, recreates path.
func (*BezierCurve) SlopeAtBezierT ¶
func (b *BezierCurve) SlopeAtBezierT(t float64) float64
SlopeAtBezierT returns the slope at a given t value of the Bezier curve.
func (*BezierCurve) SlopeAtLinearT ¶
func (b *BezierCurve) SlopeAtLinearT(t float64) float64
SlopeAtLinearT returns the slope at a given linearly interpolated point.
type Circle ¶
type Circle struct {
X, Y, Radius float64
}
Circle is the struct representing a circle.
func CircleThroughPointsWithArcHeight ¶
CircleThroughPointsWithArcHeight returns the circle that passes through the two points and creates an arc of the given height through those points.
func CircleTouchingCircle ¶
CircleTouchingCircle returns a new circle that exactly touches another circle at a given angle.
func CircleTouchingTwoCircles ¶
CircleTouchingTwoCircles returns a new circle that exactly touches the other two circles.
func NewCircleFromPoint ¶
NewCircleFromPoint creates a new circle struct using a Point object as center.
func NewCircleFromPoints ¶
NewCircleFromPoints returns a new circle that intersects the three given points. If the points are collinear, it will return nil.
func (*Circle) InnerCircles ¶
func (c *Circle) InnerCircles(count int, rotation float64) CircleList
InnerCircles returns a slice of circles arrange around the inside of the given circle.
func (*Circle) Intersection ¶
Intersection returns the points of intersection (if any) with another circles and a bool indicating whether or not they intersect at all.
func (*Circle) InvertPoint ¶
InvertPoint inverts a point into our out of a circle.
func (*Circle) OuterCircles ¶
func (c *Circle) OuterCircles(count int, rotation float64) CircleList
OuterCircles returns a slice of circles arrange around the outside of the given circle.
func (*Circle) RandomizePosition ¶
RandomizePosition randomizes the position of this triangle
func (*Circle) RandomizeRadius ¶
RandomizeRadius randomizes the radius of this triangle
func (*Circle) RandomizedPosition ¶
RandomizedPosition returns a new circle with a randomized position.
func (*Circle) RandomizedRadius ¶
RandomizedRadius returns a new circle with a randomized radius.
func (*Circle) RotateFrom ¶
RotateFrom rotates a circle around the given x, y location.
func (*Circle) RotatedFrom ¶
RotatedFrom returns a new circle rotated.
func (*Circle) ScaleFrom ¶
ScaleFrom scales this circle on the x and y axes, with the given x, y location as a center.
func (*Circle) ScaleLocal ¶
ScaleLocal scales this circle's radius only.
func (*Circle) ScaledFrom ¶
ScaledFrom returns a new circle scaled.
func (*Circle) ScaledLocal ¶
ScaledLocal returns a new circle scaled.
func (*Circle) Translated ¶
Translated returns a new circle translated.
type CircleList ¶
type CircleList []*Circle
CircleList is a slice of circles
func (*CircleList) AddXY ¶
func (c *CircleList) AddXY(x, y, r float64)
AddXY adds a circle to the list
func (*CircleList) RandomizePosition ¶
func (c *CircleList) RandomizePosition(amount float64)
RandomizePosition randomizes the position of all the circles in a list.
func (*CircleList) RandomizeRadius ¶
func (c *CircleList) RandomizeRadius(amount float64)
RandomizeRadius randomizes the position of all the circles in a list.
func (*CircleList) Rotate ¶
func (c *CircleList) Rotate(angle float64)
Rotate rotates all the circles in a list.
func (*CircleList) RotateFrom ¶
func (c *CircleList) RotateFrom(x, y float64, angle float64)
RotateFrom rotates all the circles in a list using the x, y location as a center.
func (*CircleList) Scale ¶
func (c *CircleList) Scale(scale float64)
Scale scales all the circles in a list.
func (*CircleList) ScaleFrom ¶
func (c *CircleList) ScaleFrom(x, y, scale float64)
ScaleFrom scales all the circles in a list using the x, y location as a center.
func (*CircleList) ScaleLocal ¶
func (c *CircleList) ScaleLocal(scale float64)
ScaleLocal scales all the circles in a list.
func (*CircleList) Translate ¶
func (c *CircleList) Translate(x, y float64)
Translate translates all the circles in a list.
type Line ¶
type Line Segment
Line is the same as a segment, but we'll keep them separate for collision purposes
func NewLineFromPoints ¶
NewLineFromPoints creates a new line from two Points.
func NewLineFromSegment ¶
NewLineFromSegment creates a new line from an existing Segment.
func (*Line) ClosestPoint ¶
ClosestPoint reports the point on a line closest to another given point.
func (*Line) DistanceTo ¶
DistanceTo reports the distance from a given point to this line.
func (*Line) HitSegment ¶
HitSegment reports the point of intersection of a line and a line segment.
func (*Line) Perpendicular ¶
Perpendicular returns a line that is perpendicular to the line and crosses through the given point.
type Point ¶
type Point struct {
X, Y float64
}
Point is the structure representing a 2D point.
func BezierPoint ¶
BezierPoint calculates a point along a Bezier curve.
func Bisect ¶
Bisect returns a point that will bisect the angle formed by the three points passed in.
func QuadraticPoint ¶
QuadraticPoint calculated a point along a quadratic Bezier curve.
func RandomPointInCircle ¶
RandomPointInCircle creates a random point within the defined circle. if dist is true, it will evenly distribute them in the circle.
func RandomPointInRect ¶
RandomPointInRect creates a random point within the defined rectangle.
func RandomPointInTriangle ¶
RandomPointInTriangle returns a randomly generated point within the triangle described by the given points.
func (*Point) AngleBetween ¶
AngleBetween returns the angle formed from p0 to this point to p1.
func (*Point) Normalize ¶
func (p *Point) Normalize()
Normalize normalizes each component of this point, in place.
func (*Point) Normalized ¶
Normalized returns a copy of this point, normalized.
func (*Point) Randomized ¶
Randomized returns a new point, randomized from this.
func (*Point) RotateFrom ¶
RotateFrom rotates this point around the the given x, y origin point.
func (*Point) RotatedFrom ¶
RotatedFrom creates a new point, rotated from the given x, y location.
func (*Point) ScaleFrom ¶
ScaleFrom scales this point on the x and y axes, with the given x, y location as a center.
func (*Point) ScaledFrom ¶
ScaledFrom creates a new point, scaled from a given x, y location.
func (*Point) Translated ¶
Translated creates a new point, a translated version of this point.
func (*Point) UniScaleFrom ¶
UniScaleFrom scales this point by the same amount on the x and y axes, given the x, y location as a center
func (*Point) UniScaledFrom ¶
UniScaledFrom creates a new point, scaled from a given x, y location.
type PointList ¶
type PointList []*Point
PointList is a slice of Points
func ConvexHull ¶
ConvexHull returns a list of points that form a convex hull around the given set of points.
func LineOnRect ¶
LineOnRect returns the points of intersection from a line to a rect (if any).
func LinearBezierPoints ¶
LinearBezierPoints creates a list of points roughly evenly distributed along the curve.
func PoissonDiskSampling ¶
PoissonDiskSampling returns a poisson disk sampling of points
func RandomPointList ¶
RandomPointList returns a list of random points in a given rect.
func (PointList) BoundingBox ¶
BoundingBox returns a rectangle enclosing all the points in the list.
func (PointList) Culled ¶
Culled returns a new point list of points from this list that match a test
func (*PointList) FisheyeFromPoint ¶
FisheyeFromPoint applies a fisheye transform from the given point.
func (*PointList) FisheyeFromXY ¶
FisheyeFromXY applies a fisheye transform from the given x, y location.
func (PointList) Get ¶
Get returns the point at the given index. If the index is negative, it counts from the end of the list.
func (PointList) Interpolate ¶
Interpolate returns a point interpolated along the length of this path.
func (*PointList) Normalize ¶
func (p *PointList) Normalize()
Normalize normalizes all the points in this list.
func (*PointList) Normalized ¶
Normalized normalizes all the points in this list.
func (*PointList) Randomized ¶
Randomized randomizes all the points in a list.
func (*PointList) RotateFrom ¶
RotateFrom rotates all the points in a list using the x, y location as a center.
func (*PointList) RotateLocal ¶
RotateLocal rotates all the points in a list from their local center.
func (*PointList) RotatedFrom ¶
RotatedFrom rotates all the points in a list using the x, y location as a center.
func (*PointList) ScaleFrom ¶
ScaleFrom scales all the points in a list using the x, y location as a center.
func (*PointList) ScaleLocal ¶
ScaleLocal scales all the points in a list using their local center.
func (*PointList) ScaledFrom ¶
ScaledFrom scales all the points in a list using the x, y location as a center.
func (PointList) SortDistFrom ¶
SortDistFrom sorts the list by the distance to a given x, y location
func (*PointList) Split ¶
Split removes any points from the list that do not match the test, and then returns those removed points as a new list.
func (*PointList) Translated ¶
Translated translates all the points in a list.
func (*PointList) UniScaleFrom ¶
UniScaleFrom scales all the points in a list using the x, y location as a center.
func (*PointList) UniScaleLocal ¶
UniScaleLocal scales all the points in a list using their local center.
func (*PointList) UniScaledFrom ¶
UniScaledFrom scales all the points in a list using the x, y location as a center.
func (*PointList) VortexFromPoint ¶
VortexFromPoint applies a vortex transform from the given point.
func (*PointList) VortexFromXY ¶
VortexFromXY applies a vortex transform from the given x, y location.
type Rect ¶
type Rect struct {
X, Y, W, H float64
}
Rect represents a rectangle
func NewRectFromPoints ¶
NewRectFromPoints creates a new rectangle.
func (*Rect) HitSegment ¶
HitSegment reports whether a line segment is interesecting this rectangle.
type Segment ¶
type Segment struct {
PointA, PointB *Point
}
Segment represents a line segment.
func NewSegment ¶
NewSegment creates a new line segment.
func NewSegmentFromPoints ¶
NewSegmentFromPoints creates a new line segment.
func TangentSegmentToCircles ¶
TangentSegmentToCircles returns a line segment that forms a tangent to the two given circles. There can be two such segments. The sign parameter (positive or negative) allows you to choose which one.
func (*Segment) ClosestPoint ¶
ClosestPoint returns the point on this segment closest to another point.
func (*Segment) DistanceTo ¶
DistanceTo returns the distance from this segment to another point.
func (*Segment) Equals ¶
Equals returns whether or not this segment is roughly equal to another segment.
func (*Segment) HitSegment ¶
HitSegment returns the point of intersection between this and another segment.
func (*Segment) Parallel ¶
Parallel returns a Line that is parallel to this line, a certain distance away.
func (*Segment) Randomized ¶
Randomized returns a randomized segment from this segment.
func (*Segment) RotateFrom ¶
RotateFrom rotates a segment around the given x, y location.
func (*Segment) RotateLocal ¶
RotateLocal rotates a segment around its own center.
func (*Segment) RotatedFrom ¶
RotatedFrom returns a new segment rotated from this.
func (*Segment) RotatedLocal ¶
RotatedLocal returns a new segment rotated from this.
func (*Segment) ScaleFrom ¶
ScaleFrom scales a segment the given amount on each axis, from the given x, y location.
func (*Segment) ScaleLocal ¶
ScaleLocal scales a segment the given amount on each axis from its own center
func (*Segment) ScaledFrom ¶
ScaledFrom returns a new segment scaled by the given amount.
func (*Segment) ScaledLocal ¶
ScaledLocal returns a new segment scaled by the given amount.
func (*Segment) Translated ¶
Translated returns a new segment translated from this.
func (*Segment) UniScaleFrom ¶
UniScaleFrom scales a segment using the x, y location as a center
func (*Segment) UniScaleLocal ¶
UniScaleLocal scales a segment the given amount on each axis.
func (*Segment) UniScaled ¶
UniScaled returns a new segment scaled by the given amount - the same on both axes.
func (*Segment) UniScaledFrom ¶
UniScaledFrom returns a new segment scaled from the given point.
func (*Segment) UniScaledLocal ¶
UniScaledLocal returns a new segment scaled by the given amount - the same on both axes.
type SegmentList ¶
type SegmentList []*Segment
SegmentList is a slice of segments
func (*SegmentList) Add ¶
func (s *SegmentList) Add(segment *Segment)
Add adds a segment to the list
func (*SegmentList) AddXY ¶
func (s *SegmentList) AddXY(x0, y0, x1, y1 float64)
AddXY adds a segment to the list
func (*SegmentList) Noisify ¶
func (s *SegmentList) Noisify(sx, sy, z, offset float64)
func (*SegmentList) Randomize ¶
func (s *SegmentList) Randomize(amount float64)
Randomize randomizes the position of both ends of the segment by up to a given amount on each axis.
func (*SegmentList) Rotate ¶
func (s *SegmentList) Rotate(angle float64)
Rotate rotates all the segments in a list.
func (*SegmentList) RotateFrom ¶
func (s *SegmentList) RotateFrom(x, y float64, angle float64)
RotateFrom rotates all the segments in a list using the x, y location as a center.
func (*SegmentList) RotateLocal ¶
func (s *SegmentList) RotateLocal(angle float64)
RotateLocal rotates each segment from its own center.
func (*SegmentList) Scale ¶
func (s *SegmentList) Scale(sx, sy float64)
Scale scales all the segments in a list.
func (*SegmentList) ScaleFrom ¶
func (s *SegmentList) ScaleFrom(x, y, sx, sy float64)
ScaleFrom scales all the segments in a list using the x, y location as a center.
func (*SegmentList) ScaleLocal ¶
func (s *SegmentList) ScaleLocal(sx, sy float64)
ScaleLocal scales each segment from its own center.
func (*SegmentList) Translate ¶
func (s *SegmentList) Translate(x, y float64)
Translate translates all the segments in a list.
func (*SegmentList) UniScale ¶
func (s *SegmentList) UniScale(scale float64)
UniScale scales each segment
func (*SegmentList) UniScaleFrom ¶
func (s *SegmentList) UniScaleFrom(x, y, scale float64)
UniScaleFrom scales each segment
func (*SegmentList) UniScaleLocal ¶
func (s *SegmentList) UniScaleLocal(scale float64)
UniScaleLocal scales each segment
type Triangle ¶
type Triangle struct {
PointA, PointB, PointC *Point
}
Triangle represents a triangle.
func EquilateralTriangleFromCenterAndPoint ¶
EquilateralTriangleFromCenterAndPoint creates a new equilateral triangle from a centroid point and another point.
func EquilateralTriangleFromTwoPoints ¶
EquilateralTriangleFromTwoPoints creates a new equilateral triangle from a two points.
func IsoscoleseTriangle ¶
IsoscoleseTriangle creates a new trangle with the given point and two sides of the given length with the given angle.
func NewTriangle ¶
NewTriangle creates a new triangle from three x, y pairs
func NewTriangleFromPoints ¶
NewTriangleFromPoints creates a new triangle from three points.
func (*Triangle) AltitudeLine ¶
AltitudeLine returns a line that represents the altitude from a given point to its opposite side.
func (*Triangle) BisectorLine ¶
BisectorLine returns a line segment representing the bisector from a given point to its opposite side.
func (*Triangle) CircumCenter ¶
CircumCenter returns a point representing the circumcenter of the triangle
func (*Triangle) CircumCircle ¶
CircumCircle returns a circle object representing the center and radius of the circumcircle.
func (*Triangle) Contains ¶
Contains returns whether or not the given point is contained by the triangle.
func (*Triangle) Edges ¶
func (t *Triangle) Edges() SegmentList
Edges returns the three segments that make up the triangle.
func (*Triangle) Foot ¶
Foot returns the altitude foot of a triangle (intersection of base and altitude).
func (*Triangle) InCircle ¶
InCircle returns a circle containing the center and radius of the incircle.
func (*Triangle) MedianLine ¶
MedianLine returns a line segment representing the median from a given point to its opposite side.
func (*Triangle) OrthicTriangle ¶
OrthicTriangle returns the triangle created by the foot of each corner of the triangle.
func (*Triangle) OrthoCenter ¶
OrthoCenter returns a point representing the orthocenter of the triangle.
func (*Triangle) Randomized ¶
Randomized returns another triangle that is randomized from this one.
func (*Triangle) RotateFrom ¶
RotateFrom rotates a triangle around the given x, y location.
func (*Triangle) RotateLocal ¶
RotateLocal rotates a triangle around its own center (centroid)
func (*Triangle) RotatedFrom ¶
RotatedFrom returns a new triangle rotated by the given amount.
func (*Triangle) RotatedLocal ¶
RotatedLocal returns a new triangle rotated by the given amount.
func (*Triangle) ScaleFrom ¶
ScaleFrom scales a triangle the given amount on each axis, from the given x, y location.
func (*Triangle) ScaleLocal ¶
ScaleLocal scales a triangle the given amount on each axis.
func (*Triangle) ScaledFrom ¶
ScaledFrom returns a new triangle scaled by the given amount.
func (*Triangle) ScaledLocal ¶
ScaledLocal returns a new triangle scaled by the given amount.
func (*Triangle) Translated ¶
Translated returns a new triangle translated by the given amount.
func (*Triangle) UniScaleFrom ¶
UniScaleFrom scales a triangle the given amount on each axis, from the given x, y location.
func (*Triangle) UniScaleLocal ¶
UniScaleLocal scales a triangle the given amount on each axis
func (*Triangle) UniScaled ¶
UniScaled returns a new triangle scaled by the given amount - the same on both axes.
func (*Triangle) UniScaledFrom ¶
UniScaledFrom returns a new segment scaled from the given point.
func (*Triangle) UniScaledLocal ¶
UniScaledLocal returns a new segment scaled locally
type TriangleList ¶
type TriangleList []*Triangle
TriangleList is a slice of triangles
func NewTriangleList ¶
func NewTriangleList() TriangleList
NewTriangleList creates a new triangle list
func (*TriangleList) Add ¶
func (t *TriangleList) Add(triangle *Triangle)
Add adds a Triangle to the list
func (*TriangleList) Edges ¶
func (t *TriangleList) Edges() SegmentList
Edges returns a list of unique edges from the triangle list.
func (*TriangleList) Randomize ¶
func (t *TriangleList) Randomize(amount float64)
Randomize randomizes the position of both ends of the segment by up to a given amount on each axis.
func (*TriangleList) Rotate ¶
func (t *TriangleList) Rotate(angle float64)
Rotate rotates all the segments in a list.
func (*TriangleList) RotateFrom ¶
func (t *TriangleList) RotateFrom(x, y float64, angle float64)
RotateFrom rotates all the segments in a list using the x, y location as a center.
func (*TriangleList) RotateLocal ¶
func (t *TriangleList) RotateLocal(angle float64)
RotateLocal rotates each segment from its own center.
func (*TriangleList) Scale ¶
func (t *TriangleList) Scale(sx, sy float64)
Scale scales all the segments in a list.
func (*TriangleList) ScaleFrom ¶
func (t *TriangleList) ScaleFrom(x, y, sx, sy float64)
ScaleFrom scales all the segments in a list using the x, y location as a center.
func (*TriangleList) ScaleLocal ¶
func (t *TriangleList) ScaleLocal(sx, sy float64)
ScaleLocal scales each segment from its own center.
func (*TriangleList) Translate ¶
func (t *TriangleList) Translate(x, y float64)
Translate translates all the segments in a list.
func (*TriangleList) UniScale ¶
func (t *TriangleList) UniScale(scale float64)
UniScale scales each segment
func (*TriangleList) UniScaleFrom ¶
func (t *TriangleList) UniScaleFrom(x, y, scale float64)
UniScaleFrom scales each segment
func (*TriangleList) UniScaleLocal ¶
func (t *TriangleList) UniScaleLocal(scale float64)
UniScaleLocal scales each segment
type Vector ¶
type Vector struct {
U, V float64
}
Vector is a struct representing a 2D vector.
func VectorBetween ¶
VectorBetween returns the vector between two points.
func VectorFromPoints ¶
VectorFromPoints returns the vector between two points.
func (*Vector) AngleValueTo ¶
AngleValueTo returns the angle to another vector.
func (*Vector) CrossProduct ¶
CrossProduct returns the cross product between this and another vector.
func (*Vector) DotProduct ¶
DotProduct returns the dot product between this and another vector.
func (*Vector) Max ¶
Max returns the maximum value (taken component-wise) of this vector and another value.
func (*Vector) Min ¶
Min returns the minimum value (taken component-wise) of this vector and another value.
func (*Vector) Normalized ¶
Normalized returns this vector normalized.