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.
Index ¶
- func AngleFromTriangleSideLengths(a, b, c 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 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 (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 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) AngleTo(o *Point) float64
- 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) 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 NewPointList() PointList
- func PointGrid(x, y, w, h, xres, yres float64) PointList
- func PoissonDiskSampling(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) Clone() PointList
- func (p PointList) Cull(test PointListCullTest) PointList
- func (p PointList) DeepClone() PointList
- func (p PointList) First() *Point
- func (p *PointList) Insert(index int, point *Point) error
- func (p PointList) Last() *Point
- func (p *PointList) Noisify(sx, sy, z, offset float64)
- func (p *PointList) Randomize(rx, ry float64)
- func (p *PointList) Rotate(angle float64)
- func (p *PointList) RotateFrom(x, y float64, angle float64)
- func (p *PointList) Scale(sx, sy float64)
- func (p *PointList) ScaleFrom(x, y, sx, sy float64)
- func (p PointList) SortDistFrom(x, y float64) PointList
- func (p PointList) SortXY() PointList
- func (p PointList) SortYX() PointList
- func (p *PointList) Translate(x, y float64)
- func (p *PointList) UniScale(scale float64)
- func (p *PointList) UniScaleFrom(x, y, scale float64)
- func (p PointList) Unique() PointList
- type PointListCullTest
- 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) 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) 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 (t *Triangle) Area() float64
- 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) InCenter() *Point
- func (t *Triangle) InCircle() *Circle
- 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 ¶ added in v0.4.9
AngleFromTriangleSideLengths returns one angle of a triangle where the lengths of each side are known. It returns the angle between a and b.
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 ¶ added in v0.4.12
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 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 ¶ added in v0.4.9
CircleTouchingCircle returns a new circle that exactly touches another circle at a given angle.
func CircleTouchingTwoCircles ¶ added in v0.4.9
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 (*Circle) InnerCircles ¶ added in v0.5.2
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 ¶ added in v0.5.2
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 ¶ added in v0.5.2
RandomizePosition randomizes the position of this triangle
func (*Circle) RandomizeRadius ¶ added in v0.5.2
RandomizeRadius randomizes the radius of this triangle
func (*Circle) RandomizedPosition ¶ added in v0.5.2
RandomizedPosition returns a new circle with a randomized position.
func (*Circle) RandomizedRadius ¶ added in v0.5.2
RandomizedRadius returns a new circle with a randomized radius.
func (*Circle) RotateFrom ¶ added in v0.4.13
RotateFrom rotates a circle around the given x, y location.
func (*Circle) RotatedFrom ¶ added in v0.5.2
RotatedFrom returns a new circle rotated.
func (*Circle) Scale ¶ added in v0.4.13
Scale scales this circle on the x and y axes, as well as its size.
func (*Circle) ScaleFrom ¶ added in v0.4.13
ScaleFrom scales this circle on the x and y axes, with the given x, y location as a center.
func (*Circle) ScaleLocal ¶ added in v0.5.2
ScaleLocal scales this circle's radius only.
func (*Circle) ScaledFrom ¶ added in v0.5.2
ScaledFrom returns a new circle scaled.
func (*Circle) ScaledLocal ¶ added in v0.5.2
ScaledLocal returns a new circle scaled.
func (*Circle) Translated ¶ added in v0.5.2
Translated returns a new circle translated.
type CircleList ¶ added in v0.4.13
type CircleList []*Circle
CircleList is a slice of circles
func NewCircleList ¶ added in v0.4.13
func NewCircleList() CircleList
NewCircleList creates a new circle list
func (*CircleList) Add ¶ added in v0.4.13
func (c *CircleList) Add(circle *Circle)
Add adds a circle to the list
func (*CircleList) AddXY ¶ added in v0.4.13
func (c *CircleList) AddXY(x, y, r float64)
AddXY adds a circle to the list
func (*CircleList) RandomizePosition ¶ added in v0.5.2
func (c *CircleList) RandomizePosition(amount float64)
RandomizePosition randomizes the position of all the circles in a list.
func (*CircleList) RandomizeRadius ¶ added in v0.5.2
func (c *CircleList) RandomizeRadius(amount float64)
RandomizeRadius randomizes the position of all the circles in a list.
func (*CircleList) Rotate ¶ added in v0.4.13
func (c *CircleList) Rotate(angle float64)
Rotate rotates all the circles in a list.
func (*CircleList) RotateFrom ¶ added in v0.4.13
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 ¶ added in v0.4.13
func (c *CircleList) Scale(scale float64)
Scale scales all the circles in a list.
func (*CircleList) ScaleFrom ¶ added in v0.4.13
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 ¶ added in v0.5.2
func (c *CircleList) ScaleLocal(scale float64)
ScaleLocal scales all the circles in a list.
func (*CircleList) Translate ¶ added in v0.4.13
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 (*Line) Angle ¶ added in v0.4.11
Angle returns the angle of rthis line (from the first point to the second)
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 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) Randomized ¶ added in v0.5.2
Randomized returns a new point, randomized from this.
func (*Point) RotateFrom ¶ added in v0.4.12
RotateFrom rotates this point around the the given x, y origin point.
func (*Point) Rotated ¶ added in v0.5.2
Rotated creates a new point, a rotated version of this point.
func (*Point) RotatedFrom ¶ added in v0.5.2
RotatedFrom creates a new point, rotated from the given x, y location.
func (*Point) ScaleFrom ¶ added in v0.4.12
ScaleFrom scales this point on the x and y axes, with the given x, y location as a center.
func (*Point) ScaledFrom ¶ added in v0.5.2
ScaledFrom creates a new point, scaled from a given x, y location.
func (*Point) Translated ¶ added in v0.5.2
Translated creates a new point, a translated version of this point.
func (*Point) UniScaleFrom ¶ added in v0.4.13
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 ¶ added in v0.5.2
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 PoissonDiskSampling ¶ added in v0.4.11
PoissonDiskSampling returns a poisson disk sampling of points
func RandomPointList ¶ added in v0.4.12
RandomPointList returns a list of random points in a given rect.
func (PointList) Cull ¶ added in v0.4.11
func (p PointList) Cull(test PointListCullTest) PointList
Cull returns a new point list of points from this list that match a test
func (*PointList) RotateFrom ¶ added in v0.4.12
RotateFrom rotates all the points in a list using the x, y location as a center.
func (*PointList) ScaleFrom ¶ added in v0.4.12
ScaleFrom scales all the points in a list using the x, y location as a center.
func (PointList) SortDistFrom ¶ added in v0.5.2
SortDistFrom sorts the list by the distance to a given x, y location
func (PointList) SortXY ¶ added in v0.5.2
SortXY sorts the list by x position, deciding matches with y
func (PointList) SortYX ¶ added in v0.5.2
SortYX sorts the list by y position, deciding matches with x
func (*PointList) UniScaleFrom ¶ added in v0.5.2
UniScaleFrom scales all the points in a list using the x, y location as a center.
type PointListCullTest ¶ added in v0.4.11
PointListCullTest is a function that takes a point and returns a bool. Used for culling points from a list.
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 {
X0, Y0, X1, Y1 float64
}
Segment represents a line segment.
func NewSegment ¶
NewSegment creates a new line segment.
func NewSegmentFromPoints ¶
NewSegmentFromPoints creates a new line segment.
func TangentSegmentToCircles ¶ added in v0.4.10
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 ¶ added in v0.5.0
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) Randomize ¶ added in v0.5.2
Randomize randomizes the endpoints of the segment by the given amount.
func (*Segment) Randomized ¶ added in v0.5.2
Randomized returns a randomized segment from this segment.
func (*Segment) RotateFrom ¶ added in v0.5.2
RotateFrom rotates a segment around the given x, y location.
func (*Segment) RotateLocal ¶ added in v0.5.2
RotateLocal rotates a segment around its own center.
func (*Segment) RotatedFrom ¶ added in v0.5.2
RotatedFrom returns a new segment rotated from this.
func (*Segment) RotatedLocal ¶ added in v0.5.2
RotatedLocal returns a new segment rotated from this.
func (*Segment) ScaleFrom ¶ added in v0.5.2
ScaleFrom scales a segment the given amount on each axis, from the given x, y location.
func (*Segment) ScaleLocal ¶ added in v0.5.2
ScaleLocal scales a segment the given amount on each axis from its own center
func (*Segment) ScaledFrom ¶ added in v0.5.2
ScaledFrom returns a new segment scaled by the given amount.
func (*Segment) ScaledLocal ¶ added in v0.5.2
ScaledLocal returns a new segment scaled by the given amount.
func (*Segment) Translate ¶ added in v0.5.2
Translate translates a segment the given amount on each axis.
func (*Segment) Translated ¶ added in v0.5.2
Translated returns a new segment translated from this.
func (*Segment) UniScale ¶ added in v0.5.2
UniScale scales a segment the given amount on both axes equally.
func (*Segment) UniScaleFrom ¶ added in v0.5.2
UniScaleFrom scales a segment using the x, y location as a center
func (*Segment) UniScaleLocal ¶ added in v0.5.2
UniScaleLocal scales a segment the given amount on each axis.
func (*Segment) UniScaled ¶ added in v0.5.2
UniScaled returns a new segment scaled by the given amount - the same on both axes.
func (*Segment) UniScaledFrom ¶ added in v0.5.2
UniScaledFrom returns a new segment scaled from the given point.
func (*Segment) UniScaledLocal ¶ added in v0.5.2
UniScaledLocal returns a new segment scaled by the given amount - the same on both axes.
type SegmentList ¶ added in v0.5.2
type SegmentList []*Segment
SegmentList is a slice of segments
func NewSegmentList ¶ added in v0.5.2
func NewSegmentList() SegmentList
NewSegmentList creates a new segment list
func (*SegmentList) Add ¶ added in v0.5.2
func (s *SegmentList) Add(segment *Segment)
Add adds a segment to the list
func (*SegmentList) AddXY ¶ added in v0.5.2
func (s *SegmentList) AddXY(x0, y0, x1, y1 float64)
AddXY adds a segment to the list
func (*SegmentList) Randomize ¶ added in v0.5.2
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 ¶ added in v0.5.2
func (s *SegmentList) Rotate(angle float64)
Rotate rotates all the segments in a list.
func (*SegmentList) RotateFrom ¶ added in v0.5.2
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 ¶ added in v0.5.2
func (s *SegmentList) RotateLocal(angle float64)
RotateLocal rotates each segment from its own center.
func (*SegmentList) Scale ¶ added in v0.5.2
func (s *SegmentList) Scale(sx, sy float64)
Scale scales all the segments in a list.
func (*SegmentList) ScaleFrom ¶ added in v0.5.2
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 ¶ added in v0.5.2
func (s *SegmentList) ScaleLocal(sx, sy float64)
ScaleLocal scales each segment from its own center.
func (*SegmentList) Translate ¶ added in v0.5.2
func (s *SegmentList) Translate(x, y float64)
Translate translates all the segments in a list.
func (*SegmentList) UniScale ¶ added in v0.5.2
func (s *SegmentList) UniScale(scale float64)
UniScale scales each segment
func (*SegmentList) UniScaleFrom ¶ added in v0.5.2
func (s *SegmentList) UniScaleFrom(x, y, scale float64)
UniScaleFrom scales each segment
func (*SegmentList) UniScaleLocal ¶ added in v0.5.2
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 NewTriangle ¶
NewTriangle creates a new triangle from three x, y pairs
func NewTriangleFromPoints ¶
NewTriangleFromPoints creates a new triangle from three points.
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 ¶ added in v0.5.0
func (t *Triangle) Edges() SegmentList
Edges returns the three segments that make up the triangle.
func (*Triangle) Equals ¶ added in v0.5.0
Equals returns whether or not this triangle is equal to another triangle
func (*Triangle) InCircle ¶
InCircle returns a circle containing the center and radius of the incircle.
func (*Triangle) OrthoCenter ¶
OrthoCenter returns a point representing the orthocenter of the triangle.
func (*Triangle) Randomize ¶ added in v0.5.2
Randomize randomizes the position of the three points of the triangle.
func (*Triangle) Randomized ¶ added in v0.5.2
Randomized returns another triangle that is randomized from this one.
func (*Triangle) RotateFrom ¶ added in v0.5.2
RotateFrom rotates a triangle around the given x, y location.
func (*Triangle) RotateLocal ¶ added in v0.5.2
RotateLocal rotates a triangle around its own center (centroid)
func (*Triangle) Rotated ¶ added in v0.5.2
Rotated returns a new triangle rotated by the given amount.
func (*Triangle) RotatedFrom ¶ added in v0.5.2
RotatedFrom returns a new triangle rotated by the given amount.
func (*Triangle) RotatedLocal ¶ added in v0.5.2
RotatedLocal returns a new triangle rotated by the given amount.
func (*Triangle) ScaleFrom ¶ added in v0.5.2
ScaleFrom scales a triangle the given amount on each axis, from the given x, y location.
func (*Triangle) ScaleLocal ¶ added in v0.5.2
ScaleLocal scales a triangle the given amount on each axis.
func (*Triangle) ScaledFrom ¶ added in v0.5.2
ScaledFrom returns a new triangle scaled by the given amount.
func (*Triangle) ScaledLocal ¶ added in v0.5.2
ScaledLocal returns a new triangle scaled by the given amount.
func (*Triangle) Translate ¶ added in v0.5.2
Translate translates a triangle the given amount on each axis.
func (*Triangle) Translated ¶ added in v0.5.2
Translated returns a new triangle translated by the given amount.
func (*Triangle) UniScale ¶ added in v0.5.2
UniScale scales a triangle the given amount on each axis.
func (*Triangle) UniScaleFrom ¶ added in v0.5.2
UniScaleFrom scales a triangle the given amount on each axis, from the given x, y location.
func (*Triangle) UniScaleLocal ¶ added in v0.5.2
UniScaleLocal scales a triangle the given amount on each axis
func (*Triangle) UniScaled ¶ added in v0.5.2
UniScaled returns a new triangle scaled by the given amount - the same on both axes.
func (*Triangle) UniScaledFrom ¶ added in v0.5.2
UniScaledFrom returns a new segment scaled from the given point.
func (*Triangle) UniScaledLocal ¶ added in v0.5.2
UniScaledLocal returns a new segment scaled locally
type TriangleList ¶ added in v0.5.2
type TriangleList []*Triangle
TriangleList is a slice of triangles
func NewTriangleList ¶ added in v0.5.2
func NewTriangleList() TriangleList
NewTriangleList creates a new triangle list
func (*TriangleList) Add ¶ added in v0.5.2
func (t *TriangleList) Add(triangle *Triangle)
Add adds a Triangle to the list
func (*TriangleList) Edges ¶ added in v0.5.2
func (t *TriangleList) Edges() SegmentList
Edges returns a list of unique edges from the triangle list.
func (*TriangleList) Randomize ¶ added in v0.5.2
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 ¶ added in v0.5.2
func (t *TriangleList) Rotate(angle float64)
Rotate rotates all the segments in a list.
func (*TriangleList) RotateFrom ¶ added in v0.5.2
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 ¶ added in v0.5.2
func (t *TriangleList) RotateLocal(angle float64)
RotateLocal rotates each segment from its own center.
func (*TriangleList) Scale ¶ added in v0.5.2
func (t *TriangleList) Scale(sx, sy float64)
Scale scales all the segments in a list.
func (*TriangleList) ScaleFrom ¶ added in v0.5.2
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 ¶ added in v0.5.2
func (t *TriangleList) ScaleLocal(sx, sy float64)
ScaleLocal scales each segment from its own center.
func (*TriangleList) Translate ¶ added in v0.5.2
func (t *TriangleList) Translate(x, y float64)
Translate translates all the segments in a list.
func (*TriangleList) UniScale ¶ added in v0.5.2
func (t *TriangleList) UniScale(scale float64)
UniScale scales each segment
func (*TriangleList) UniScaleFrom ¶ added in v0.5.2
func (t *TriangleList) UniScaleFrom(x, y, scale float64)
UniScaleFrom scales each segment
func (*TriangleList) UniScaleLocal ¶ added in v0.5.2
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) Abs ¶ added in v0.4.13
Abs returns the absolute value (taken component-wise) of this vector.
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) Magnitude ¶ added in v0.4.11
Magnitude returns the magnitude (length) of this vector.
func (*Vector) Max ¶ added in v0.4.13
Max returns the maximum value (taken component-wise) of this vector and another value.
func (*Vector) Min ¶ added in v0.4.13
Min returns the minimum value (taken component-wise) of this vector and another value.
func (*Vector) Normalized ¶
Normalized returns this vector normalized.