Documentation
¶
Index ¶
- Variables
- func Abs[T constraints.Signed](x T) T
- func Clamp[T Number](n, low, high T) T
- func DegreesToRadians(degrees float64) float64
- func Float64NearZero(v float64, tolerance float64) bool
- func FloatsEqual(a, b float64) bool
- func FloatsEqualTol(a, b, tolerance float64) bool
- func Fmt(a any, params any) fmt.Stringer
- func IsCollinear[T Number](p1, p2, p3 Point[T]) bool
- func Max[T Number](a, b T) T
- func Min[T Number](a, b T) T
- func Nearest[T Number](base, a, b T) int
- func NullHitTest(PtF) bool
- func OnSegment[T Number](p, start, end Point[T]) bool
- func Orient[T Number](a, b, c Point[T]) T
- func Pt3EquaTol(a, b Pt3dF, tol float64) bool
- func Pt3Equal(a, b Pt3dF) bool
- func Pt3dNearZero(v Pt3dF, tolerance float64) bool
- func RadiansToDegrees(radians float64) float64
- func Ratio(a, b float64) float64
- func RectsEqual[T Number](a, b Rectangle[T]) bool
- func Sign[T SignedNumber](n T) T
- func Sqr[T Number](x T) T
- func XAtY(s SegF, y float64) (float64, bool)
- func XYToIndex[T constraints.Integer](width, height T, pt Point[T]) (T, error)
- func XYToIndexFast[T constraints.Integer](x, y, width T) T
- type Angle
- type BezF
- type CircleHitTest
- type CubicBezier
- type Float
- type HitTest
- type InterpolatorReader
- type InterpolatorReader3d
- type Line
- type LnF
- type Mode
- type Number
- type Orientation
- type Point
- func Centroid[T Number](pts []Point[T]) Point[T]
- func ConvertPoint[A Number, B Number](a Point[A]) Point[B]
- func FindIntersection[T Number](s1, s2 Segment[T]) (Point[T], bool)
- func IndexToXY[T constraints.Integer](width, height, index T) (Point[T], error)
- func LerpPoint[T Number](a, b Point[T], amount float64) Point[T]
- func LerpPointXY[T Number](a, b Point[T], xAmount, yAmount float64) Point[T]
- func PerpendicularIntersection[T Float](seg Segment[T], pt Point[T]) (Point[T], bool)
- func Pt[T Number](x, y T) Point[T]
- func Pts[T Number](xys ...T) []Point[T]
- func (a Point[T]) Add(b Point[T]) Point[T]
- func (a Point[T]) AddValue(v T) Point[T]
- func (p Point[T]) Area() T
- func (a Point[T]) Cross(b Point[T]) T
- func (a Point[T]) Degrees(b Point[T]) float64
- func (a Point[T]) Dist(b Point[T]) float64
- func (a Point[T]) DistSquared(b Point[T]) T
- func (a Point[T]) Dot(b Point[T]) float64
- func (a Point[T]) Inside(r Rectangle[T]) bool
- func (a Point[T]) Length() float64
- func (a Point[T]) Magnitude() float64
- func (a Point[T]) MulScalar(scalar T) Point[T]
- func (a Point[T]) Mult(b Point[T]) Point[T]
- func (a Point[T]) Normalize() Point[T]
- func (v Point[T]) Perpendicular() Point[T]
- func (a Point[T]) Project(m, dist float64) (Point[T], Point[T])
- func (a Point[T]) ProjectDegree(deg, dist float64) Point[T]
- func (a Point[T]) ProjectRadians(radians, dist float64) Point[T]
- func (a Point[T]) Radians() float64
- func (a Point[T]) Rotate(origin Point[T], angleInRads float64) Point[T]
- func (a Point[T]) Sub(b Point[T]) Point[T]
- func (a Point[T]) SubValue(v T) Point[T]
- func (p Point[T]) To3d(z T) Point3d[T]
- func (p Point[T]) ToIndex(xy Point[T]) T
- type Point3d
- func ConvertPoint3[A Number, B Number](a Point3d[A]) Point3d[B]
- func LerpPoint3d[T Number](a, b Point3d[T], amount float64) Point3d[T]
- func LerpPoint3dXYZ[T Number](a, b Point3d[T], xAmount, yAmount, zAmount float64) Point3d[T]
- func Pt3[T Number](x, y, z T) Point3d[T]
- func Pt3d[T Number](x, y, z T) Point3d[T]
- func (a Point3d[T]) Add(b Point3d[T]) Point3d[T]
- func (a Point3d[T]) ClampFast(rng Range[T]) Point3d[T]
- func (a Point3d[T]) Cross(b Point3d[T]) Point3d[T]
- func (a Point3d[T]) Distance(b Point3d[T]) float64
- func (a Point3d[T]) Distance2(b Point3d[T]) float64
- func (a Point3d[T]) DistanceSquared(b Point3d[T]) T
- func (a Point3d[T]) DistanceSquared2(b Point3d[T]) T
- func (a Point3d[T]) Div(b Point3d[T]) Point3d[T]
- func (a Point3d[T]) DivT(t T) Point3d[T]
- func (a Point3d[T]) Dot(b Point3d[T]) T
- func (a Point3d[T]) DotProduct(b Point3d[T]) T
- func (a Point3d[T]) LengthSq() float64
- func (a Point3d[T]) Magnitude() float64
- func (a Point3d[T]) Mult(b Point3d[T]) Point3d[T]
- func (a Point3d[T]) MultScalar(t T) Point3d[T]
- func (a Point3d[T]) MultT(t T) Point3d[T]
- func (a Point3d[T]) Normalize() Point3d[T]
- func (v Point3d[T]) RotateX(angle float64) Point3d[T]
- func (v Point3d[T]) RotateY(angle float64) Point3d[T]
- func (v Point3d[T]) RotateZ(angle float64) Point3d[T]
- func (a Point3d[T]) Scale(t T) Point3d[T]
- func (a Point3d[T]) Sub(b Point3d[T]) Point3d[T]
- func (a Point3d[T]) SubT(t T) Point3d[T]
- func (a Point3d[T]) XY() Point[T]
- type PointInterpolator
- type PointInterpolator3d
- type PointReader
- type PointReader3d
- type Poly
- type PolyF
- type PolyF64
- type PolyI
- type PolyI64
- type PolyUI64
- type PolygonBB
- type PolygonBBF64
- type ProcessPtF64Func
- type Pt3dF
- func LinePlaneIntersection(lineA, lineB Pt3dF, planeNormal, planeOrigin Pt3dF) (Pt3dF, bool)
- func NearestPointOnSegment3(segment Seg3dF, p Pt3dF) Pt3dF
- func PointOnSegmentSquaredXY(seg Seg3dF, p PtF) (Pt3dF, float64)
- func PointOnSegmentXY(seg Seg3dF, p PtF) (Pt3dF, float64)
- func TrianglePlaneIntersection(tri Tri3dF, triPt Pt3dF, planeTri Tri3dF, planePt Pt3dF) (Pt3dF, bool)
- func TrianglePlaneIntersection2(tri Tri3dF, triPt Pt3dF, planeTri Tri3dF, planePt Pt3dF) (Pt3dF, bool)
- func TrianglePlaneIntersection5(tri Tri3dF, triPt Pt3dF, planeTri Tri3dF, planePt Pt3dF) (Pt3dF, bool)
- type Pt3dF32
- type Pt3dF64
- type Pt3dI
- type Pt3dI64
- type PtF
- func CubicBezierDistance(cb CubicBezier, pt PtF) (float64, PtF)
- func CubicBezierDistanceSquared(cb CubicBezier, pt PtF) (float64, PtF)
- func DegreesToDirectionCw(degrees float64) PtF
- func DistPointToSegment(seg SegF, p PtF) (float64, PtF)
- func DistSquared(seg SegF, p PtF) (float64, PtF)
- func DistToPolyF(poly []PtF, pt PtF) (float64, PtF)
- func LineLineIntersectionF(l1, l2 LnF) (PtF, bool)
- func LineToSegIntersection(A, B PtF, pq SegF) (PtF, bool)
- func PtToSegIntersection(pt, direction PtF, seg SegF) (PtF, bool)
- func PtToSegIntersection_Off(pt, direction PtF, seg SegF) (PtF, bool)
- func PtToSegIntersection_Off2(pt, direction PtF, seg SegF) (PtF, bool)
- func QuadraticBezierDistanceBrute(cb QuadraticBezier, pt PtF) (float64, PtF)
- func QuadraticBezierDistanceSquared(cb QuadraticBezier, pt PtF) (float64, PtF)
- func QuadraticBezierDistanceSquaredBrute(cb QuadraticBezier, pt PtF) (float64, PtF)
- type PtF32
- type PtF64
- type PtI
- type PtI64
- type QuadraticBezier
- func (q *QuadraticBezier) At(t float64) PtF
- func (q QuadraticBezier) FirstDerivative(t float64) PtF
- func (q *QuadraticBezier) PointAt(t float64) PtF
- func (b *QuadraticBezier) PointBounds() RectF
- func (q *QuadraticBezier) PointOnCurve(t float64) PtF
- func (q QuadraticBezier) SecondDerivative() PtF
- func (b QuadraticBezier) String() string
- type QuadraticBezier3d
- type Range
- func (p Range[T]) Clamp(value T) T
- func (r Range[T]) ClampFast(value T) T
- func (p Range[T]) Clip(value T) T
- func (p Range[T]) Contains(value T) bool
- func (a Range[T]) Intersection(b Range[T]) Range[T]
- func (p Range[T]) MapNormal(normal float64) T
- func (p Range[T]) Midpoint() T
- func (p Range[T]) Normalize(value T) float64
- func (a Range[T]) Overlaps(b Range[T]) bool
- type RectF
- type RectF32
- type RectF64
- type RectI
- type RectI64
- type Rectangle
- func (r1 Rectangle[T]) Add(l, t, r, b T) Rectangle[T]
- func (r Rectangle[T]) Area() T
- func (r Rectangle[T]) Center() Point[T]
- func (r1 Rectangle[T]) Clip(r2 Rectangle[T]) Rectangle[T]
- func (r1 Rectangle[T]) Contains(r2 Rectangle[T]) bool
- func (r Rectangle[T]) ContainsPoint(pt Point[T]) bool
- func (r Rectangle[T]) Height() T
- func (r Rectangle[T]) Inverted() bool
- func (r Rectangle[T]) IsZero() bool
- func (r Rectangle[T]) LT() Point[T]
- func (r1 Rectangle[T]) MergePoint(x, y T) Rectangle[T]
- func (r1 Rectangle[T]) Overlaps(r2 Rectangle[T]) bool
- func (r Rectangle[T]) RB() Point[T]
- func (r Rectangle[T]) Rounded() Rectangle[T]
- func (r Rectangle[T]) Size() Point[T]
- func (r Rectangle[T]) String() string
- func (r Rectangle[T]) Translate(pt Point[T]) Rectangle[T]
- func (r1 Rectangle[T]) Union(r2 Rectangle[T]) Rectangle[T]
- func (r Rectangle[T]) Width() T
- func (r Rectangle[T]) WithExpand(v T) Rectangle[T]
- func (r Rectangle[T]) WithSize(pt Point[T]) Rectangle[T]
- type RngF
- type RngF32
- type RngF64
- type RngI
- type RngI64
- type Seg3dF
- type Seg3dF64
- type SegF
- type SegF32
- type SegF64
- type SegFmtF
- type SegI
- type SegI64
- type Segment
- func (s Segment[T]) AddPt(pt Point[T]) Segment[T]
- func (s Segment[T]) AsArray() []Point[T]
- func (s Segment[T]) Degrees() float64
- func (s Segment[T]) Dir() Point[T]
- func (s Segment[T]) Interp(unit T) Point[T]
- func (s Segment[T]) Len() T
- func (s Segment[T]) LenSquared() T
- func (s Segment[T]) Midpoint() Point[T]
- func (s Segment[T]) PerpendicularSlope() Slope
- func (s Segment[T]) Slope() Slope
- type Segment3d
- type SignedNumber
- type Size
- type SliceReader
- type SliceReader3d
- type SliceSegFmtF
- type Slope
- type Tri3dF
- type Triangle3d
Constants ¶
This section is empty.
Variables ¶
var ( HorizontalSlope = Slope{Angle: Horizontal, M: 0.} VerticalSlope = Slope{Angle: Vertical, M: math.MaxFloat64} )
var RngFUnit = RngF{Min: 0., Max: 1.}
Functions ¶
func Abs ¶
func Abs[T constraints.Signed](x T) T
func DegreesToRadians ¶
func Float64NearZero ¶
func FloatsEqual ¶
func FloatsEqualTol ¶
func IsCollinear ¶
IsCollinear checks if three points are collinear
func Min ¶
func Min[T Number](a, b T) T
Surely these are SOMEWHERE? TODO: Yes, builtin min() and max(), and they are highly optimized, perform the same as this. So remove these.
func NullHitTest ¶
func Orient ¶
Orient answers whether C is left / clockwise to direct segment AB. Response: 0: C is collinear < 0: C is left / clockwise > 0: C is right / counterclockwise
func Pt3EquaTol ¶
func Pt3dNearZero ¶
func RadiansToDegrees ¶
func RectsEqual ¶
func Sign ¶
func Sign[T SignedNumber](n T) T
func XAtY ¶
XAtY answers the X value for this segment at the given Y value, or false if the line does not intersect y.
func XYToIndex ¶
func XYToIndex[T constraints.Integer](width, height T, pt Point[T]) (T, error)
XYToIndex converts an X, Y to a flat index.
func XYToIndexFast ¶
func XYToIndexFast[T constraints.Integer](x, y, width T) T
XYToIndexFast converts an X, Y to a flat index without any bounds checking.
Types ¶
type BezF ¶
type BezF = QuadraticBezier
type CircleHitTest ¶
type CircleHitTest struct {
// contains filtered or unexported fields
}
func (*CircleHitTest) Hit ¶
func (t *CircleHitTest) Hit(pt PtF) bool
func (*CircleHitTest) Set ¶
func (t *CircleHitTest) Set(center PtF, radius float64)
func (*CircleHitTest) String ¶
func (t *CircleHitTest) String() string
type CubicBezier ¶
type CubicBezier struct {
P0, P1, P2, P3 PtF
}
CubicBezier represents a cubic Bezier curve.
func CubicBez ¶
func CubicBez(x0, y0, x1, y1, x2, y2, x3, y3 float64) CubicBezier
CubicBez is shorthand for creating a cubic bezier curve.
func (*CubicBezier) At ¶
func (bc *CubicBezier) At(t float64) PtF
At evaluates the Bezier curve at a given parameter t.
func (*CubicBezier) PointBounds ¶
func (bc *CubicBezier) PointBounds() RectF
PointBounds is the bounding box for my control points. It does not include any point that lies outside the controls.
type Float ¶
type Float interface { constraints.Float }
type InterpolatorReader ¶
type InterpolatorReader struct { Source PointInterpolator Step float64 // contains filtered or unexported fields }
InterpolatorReader converts a PointInterpolator into a reader, supplying all interpolated points from 0 - 1 based on step.
func (*InterpolatorReader) ReadPoint ¶
func (r *InterpolatorReader) ReadPoint() (PtF, error)
func (*InterpolatorReader) Reset ¶
func (r *InterpolatorReader) Reset()
func (*InterpolatorReader) SetSource ¶
func (r *InterpolatorReader) SetSource(src PointInterpolator)
SetSource will also reset the state.
type InterpolatorReader3d ¶
type InterpolatorReader3d struct { Source PointInterpolator3d Step float64 // contains filtered or unexported fields }
InterpolatorReader3d converts a PointInterpolator3d into a reader, supplying all interpolated points from 0 - 1 based on step.
func (*InterpolatorReader3d) ReadPoint ¶
func (r *InterpolatorReader3d) ReadPoint() (Pt3dF, error)
func (*InterpolatorReader3d) Reset ¶
func (r *InterpolatorReader3d) Reset()
func (*InterpolatorReader3d) SetSource ¶
func (r *InterpolatorReader3d) SetSource(src PointInterpolator3d)
SetSource will also reset the state.
type Line ¶
https://github.com/vlecomte/cp-geo/blob/master/basics/line.tex
func LineFromDir ¶
From direction vector v and offset c
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
type Orientation ¶
type Orientation uint8
const ( Collinear Orientation = iota Clockwise CounterClockwise )
func RadialDist ¶
func RadialDist(a, b float64) (float64, Orientation)
RadialDist answers the distance between two unit values, accounting for wrapping. Andswer 0 - 1, with 1 being the two values are closest. Examples: a=.1, b=.9, distance is .2, i.e. it wraps around 1.
type Point ¶
type Point[T Number] struct { X T Y T }
func FindIntersection ¶
FindIntersection finds the intersection between two line segments. Note: I am finding cases where this doesn't work, where an intersection is found on some segments but if you scale one of the points further out, no intersection. From https://github.com/vlecomte/cp-geo/blob/master/basics/segment.tex Further note: This doesn't seem to find intersections exactly on end points. Further review of that page shows yes this is correct, there's a different algorithm to account for endpoints.
func IndexToXY ¶
func IndexToXY[T constraints.Integer](width, height, index T) (Point[T], error)
IndexToXY converts a flat index into an array into an XY position.
func PerpendicularIntersection ¶
PerpendicularIntersection finds the intersection of point to the line segment by drawing a perpendicular line from point to segment. Note: this is from Gemini. Seems to work but not heavily tested.
func (Point[T]) Degrees ¶
Degrees finds the angle of the segment with this point as the origin. Degrees will be 0-360, with 0/360 on the right, proceeding clockwise.
func (Point[T]) DistSquared ¶
Dist2 is the distance without the square root.
func (Point[T]) Length ¶
Length is the magnitude of the point. I *think* this is just more standard nomenclature than Magnitude.
func (Point[T]) Normalize ¶
Normalize normalizs the point to a unit. Can be negative if they are generated from a negative point, i.e. a negative direction vector.
func (Point[T]) Perpendicular ¶
Perpendicular returns a vector perpendicular to v (rotated 90 degrees clockwise).
func (Point[T]) Project ¶
Given slope m and distance, project the positive and negative points on the line. Uses upper-left coordinate system.
func (Point[T]) ProjectDegree ¶
ProjectDegree takes a degree and distance and projects a new point.
func (Point[T]) ProjectRadians ¶
ProjectRadians takes a radian and distance and projects a new point.
func (Point[T]) Rotate ¶
Rotate the point. Rotation will be: In Quandrant 4 this rotates CW for positive angles and CCW for negative. TODO: API might be confusing, after not using it I've started thinking of the a point as the center and the point being passed in as the point to rotate. so might switch those.
type Point3d ¶
type Point3d[T Number] struct { X T Y T Z T }
func LerpPoint3dXYZ ¶
func (Point3d[T]) Cross ¶
Cross calculates the cross product of two vectors and returns a new vector
func (Point3d[T]) DistanceSquared ¶
func (Point3d[T]) DistanceSquared2 ¶
DistanceSquared2 is the DistanceSquared2 function but only using 2 components.
func (Point3d[T]) DotProduct ¶
func (Point3d[T]) MultScalar ¶
func (Point3d[T]) RotateX ¶
RotateX rotates a Vector3 around the X-axis by a given angle (in radians).
func (Point3d[T]) RotateY ¶
RotateY rotates a Vector3 around the Y-axis by a given angle (in radians).
type PointInterpolator ¶
type PointInterpolator3d ¶
type PointReader ¶
type PointReader3d ¶
type PolygonBBF64 ¶
type ProcessPtF64Func ¶
type Pt3dF ¶
func LinePlaneIntersection ¶
func NearestPointOnSegment3 ¶
NearestPointOnSegment3 finds the nearest point on a line segment to a given point.
func PointOnSegmentSquaredXY ¶
PointOnSegmentSquaredXY finds the nearest point from p to seg, but only considers the XY components, then interpolates the Z from the segment endpoints.
type PtF ¶
func CubicBezierDistance ¶
func CubicBezierDistance(cb CubicBezier, pt PtF) (float64, PtF)
CubicBezierDistance approximates the distance from a point to a Bezier curve
func CubicBezierDistanceSquared ¶
func CubicBezierDistanceSquared(cb CubicBezier, pt PtF) (float64, PtF)
CubicBezierDistanceSquared approximates the distance from a point to a Bezier curve
func DegreesToDirectionCw ¶
DegreesToDirectionCcw converts degrees to a direction vector, where 0 = right and it continues clockwise, so 90 is down.
func DistPointToSegment ¶
DistPointToSegment answers the distance from the point to the segment, as well as the point found on the segment. From https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
func DistSquared ¶
DistSquared answers the squared distance from the point to the segment, as well as the point found on the segment. From https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
func LineLineIntersectionF ¶
LineLineIntersectionF provides the intersection of two lines. https://github.com/vlecomte/cp-geo/blob/master/basics/line.tex
func LineToSegIntersection ¶
https://stackoverflow.com/questions/34415671/intersection-of-a-line-with-a-line-segment-in-c line segment p-q intersect with line A-B. This looks a lot more efficient than the current seg-seg test I'm doing, but also I actually want a seg-seg test because this gives false positives. So... maybe I'll switch to it if I think of a way for it to make sense, but probably not because this is just a different operation.
func PtToSegIntersection_Off ¶
func QuadraticBezierDistanceBrute ¶
func QuadraticBezierDistanceBrute(cb QuadraticBezier, pt PtF) (float64, PtF)
QuadraticBezierDistanceBrute approximates the distance from a point to a Bezier curve
func QuadraticBezierDistanceSquared ¶
func QuadraticBezierDistanceSquared(cb QuadraticBezier, pt PtF) (float64, PtF)
QuadraticBezierDistanceSquared approximates the distance from a point to a Bezier curve
func QuadraticBezierDistanceSquaredBrute ¶
func QuadraticBezierDistanceSquaredBrute(cb QuadraticBezier, pt PtF) (float64, PtF)
QuadraticBezierDistanceSquaredBrute approximates the distance from a point to a Bezier curve
type QuadraticBezier ¶
type QuadraticBezier struct {
P0, P1, P2 PtF
}
QuadraticBezier represents a quadratic Bezier curve.
func Bez ¶
func Bez(x0, y0, x1, y1, x2, y2 float64) QuadraticBezier
Bez is shorthand for creating a quadratic bezier curve.
func QuadraticBez ¶
func QuadraticBez(x0, y0, x1, y1, x2, y2 float64) QuadraticBezier
QuadraticBez is shorthand for creating a quadratic bezier curve.
func (*QuadraticBezier) At ¶
func (q *QuadraticBezier) At(t float64) PtF
At evaluates the Bezier curve at a given parameter t. deprecated, move to PointAt
func (QuadraticBezier) FirstDerivative ¶
func (q QuadraticBezier) FirstDerivative(t float64) PtF
FirstDerivative calculates the first derivative at t
func (*QuadraticBezier) PointAt ¶
func (q *QuadraticBezier) PointAt(t float64) PtF
PointAt evaluates the Bezier curve at a given parameter t. It satisfies the PointInterpolator interface.
func (*QuadraticBezier) PointBounds ¶
func (b *QuadraticBezier) PointBounds() RectF
PointBounds is the bounding box for my control points. It does not include any point that lies outside the controls.
func (*QuadraticBezier) PointOnCurve ¶
func (q *QuadraticBezier) PointOnCurve(t float64) PtF
deprecated, move to PointAt
func (QuadraticBezier) SecondDerivative ¶
func (q QuadraticBezier) SecondDerivative() PtF
SecondDerivative calculates the second derivative (constant for quadratic)
func (QuadraticBezier) String ¶
func (b QuadraticBezier) String() string
type QuadraticBezier3d ¶
type QuadraticBezier3d struct {
P0, P1, P2 Pt3dF
}
QuadraticBezier3D is a 3D quadratic Bézier curve. defined by three control points.
func (QuadraticBezier3d) PointAt ¶
func (q QuadraticBezier3d) PointAt(t float64) Pt3dF
PointAt evaluates the Bezier curve at a given parameter t (0 <= t <= 1). It satisfies the PointInterpolator interface.
type Range ¶
type Range[T Number] struct { Min T Max T }
func (Range[T]) Clamp ¶
func (p Range[T]) Clamp(value T) T
Clamp returns the value clipped to my range.
func (Range[T]) ClampFast ¶
func (r Range[T]) ClampFast(value T) T
ClampFast returns the value clipped to my range. It assumes Min is less than Max.
func (Range[T]) Clip ¶
func (p Range[T]) Clip(value T) T
Clip returns the value clipped to my range. TODO: Clamp() seems more common so switch to that.
func (Range[T]) Intersection ¶
Intersection returns the intersection of A and B ranges.
type Rectangle ¶
type Rectangle[T Number] struct { L, T, R, B T }
func PolygonBounds ¶
func (Rectangle[T]) ContainsPoint ¶
ContainsPoint returns true if the point is inside the half-closed rectangle.
func (Rectangle[T]) Inverted ¶
Inverted returns true if either the right is less than the left or the bottom is less than the top. It can be used as an "invalid" value in cases where a 0 rect is insufficient.
func (Rectangle[T]) MergePoint ¶
MergePoint will expand the bounds to include the point.
func (Rectangle[T]) Rounded ¶
Rounded answers the rect with all values rounded to the nearest whole number.
func (Rectangle[T]) WithExpand ¶
Expand adds the value to all edges.
type Segment ¶
Segment represents a line segment with start and end points
func (Segment[T]) Degrees ¶
Degrees finds the angle of the segment with A as the origin. Degrees will be 0-360, with 0/360 on the right, proceeding clockwise.
func (Segment[T]) Interp ¶
Interp answers a new point at the unit position on this segment, where 0. = A and 1. = B. Note this really only works on floats, need a way to narrow that constraint.
func (Segment[T]) LenSquared ¶
func (s Segment[T]) LenSquared() T
LenSquared answers the squared length of this segment.
func (Segment[T]) PerpendicularSlope ¶
PerpendicularSlope answers the perpendicular of Slope.
type Segment3d ¶
Segment represents a line segment with start and end points
type SignedNumber ¶
type SignedNumber interface { constraints.Signed | constraints.Float }
type SliceReader ¶
type SliceReader struct { Pts []PtF // contains filtered or unexported fields }
SliceReader wraps a point slice into a PointReader.
func (*SliceReader) ReadPoint ¶
func (r *SliceReader) ReadPoint() (PtF, error)
type SliceReader3d ¶
type SliceReader3d struct { Pts []PtF // contains filtered or unexported fields }
SliceReader3d wraps a point slice into a PointReader.
func (*SliceReader3d) ReadPoint ¶
func (r *SliceReader3d) ReadPoint() (PtF, error)
type SliceSegFmtF ¶
type SliceSegFmtF struct {
Segs []SegF
}
func (SliceSegFmtF) String ¶
func (f SliceSegFmtF) String() string
type Tri3dF ¶
type Tri3dF = Triangle3d[float64]
type Triangle3d ¶
func Tri3d ¶
func Tri3d[T Number](a, b, c Point3d[T]) Triangle3d[T]
Tri3d is shorthand for creating a triangle.
func Tri3dFlat ¶
func Tri3dFlat[T Number](ax, ay, az, bx, by, bz, cx, cy, cz T) Triangle3d[T]
func (Triangle3d[T]) Center ¶
func (t Triangle3d[T]) Center() Point3d[T]
func (Triangle3d[T]) SurfaceNormal ¶
func (t Triangle3d[T]) SurfaceNormal() Point3d[T]
https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal You will generally want to normalize the returned vector.