Documentation ¶
Index ¶
- Constants
- func Cross2D(a, b, c D2) float64
- func Distance2D(p1, p2 D2) float64
- func Dot2D(p1, p2 D2) float64
- func F64eq(f1, f2 float64) bool
- func HzCross2D(a, b, c D2) float64
- func IsAbove(a, b, c D2) bool
- func IsBelow(a, b, c D2) bool
- func IsColinear(a, b, c D2) bool
- func IsColinearOrAbove(a, b, c D2) bool
- func IsColinearOrBelow(a, b, c D2) bool
- func IsColinearOrLeft(a, b, c D2) bool
- func IsColinearOrRight(a, b, c D2) bool
- func IsLeftOf(a, b, c D2) bool
- func IsRightOf(a, b, c D2) bool
- func Round(num float64) int
- func ToFixed(num float64, precision int) float64
- func VertCross2D(a, b, c D2) float64
- func VerticalCompare(dp D2, e Spanning) search.CompareResult
- type D1
- type D2
- type D3
- type Dimensional
- type FullEdge
- func (fe FullEdge) At(i int) Dimensional
- func (fe FullEdge) BothPoints() (D3, D3)
- func (fe FullEdge) Bottom() D3
- func (fe FullEdge) D() int
- func (fe FullEdge) Eq(s Spanning) bool
- func (fe FullEdge) High(d int) Dimensional
- func (fe FullEdge) Inner() D3
- func (fe FullEdge) Left() D3
- func (fe FullEdge) Len() int
- func (fe FullEdge) Low(d int) Dimensional
- func (fe FullEdge) Outer() D3
- func (fe FullEdge) PointAt(d int, v float64) (Point, error)
- func (fe FullEdge) Right() D3
- func (fe FullEdge) Set(i int, d Dimensional) Spanning
- func (fe FullEdge) Slope() float64
- func (fe FullEdge) SubEdge(d int, v1, v2 float64) (FullEdge, error)
- func (fe FullEdge) Top() D3
- type Point
- func (dp Point) Bounds() S3
- func (dp Point) Cross2D(p2, p3 D2) float64
- func (dp Point) D() int
- func (dp Point) Dot2D(p2 D2) float64
- func (dp Point) Eq(p2 Dimensional) bool
- func (dp Point) Greater2D(p2 D2) D2
- func (dp Point) Lesser2D(p2 D2) D2
- func (dp Point) Magnitude2D() float64
- func (dp Point) Mid2D(p2 D2) Point
- func (dp Point) Set(i int, v float64) Dimensional
- func (dp Point) String() string
- func (dp Point) Val(d int) float64
- func (dp Point) X() float64
- func (dp Point) Y() float64
- func (dp Point) Z() float64
- type S1
- type S2
- type S3
- type Span
- func (sp Span) Bottom() D3
- func (sp Span) Diff() D3
- func (sp Span) Eq(s Spanning) bool
- func (sp Span) Expand(ps ...Dimensional) Span
- func (sp Span) Greater(d int) Dimensional
- func (sp Span) High(i int) Dimensional
- func (sp Span) Inner() D3
- func (sp Span) Left() D3
- func (sp Span) Lesser(d int) Dimensional
- func (sp Span) Low(i int) Dimensional
- func (sp Span) Outer() D3
- func (sp Span) Right() D3
- func (sp Span) Set(i int, d Dimensional) Spanning
- func (sp Span) Top() D3
- type Spanning
Constants ¶
const ( // Inf is shorthand for math.MaxFloat64 Inf = math.MaxFloat64 // NegInf is shorthand for math.MaxFloat64 * -1 NegInf = -math.MaxFloat64 )
const ( // SPAN_MIN refers to the point in a span // which it holds its minimum value in. SPAN_MIN = iota // SPAN_MAX returns to the index in a span // which it holds its maximum value in. SPAN_MAX )
const (
// POINT_DIM is the number of dimensions a point holds.
POINT_DIM = 3
)
Variables ¶
This section is empty.
Functions ¶
func Distance2D ¶
func IsColinear ¶
IsColinear returns whether the cross product reports 0.
func IsColinearOrAbove ¶
IsColinearOrAbove is equivalent to calling IsColinear || IsAbove without redoing the cross product calculation.
func IsColinearOrBelow ¶
IsColinearOrBelow is equivalent to calling IsColinear || IsBelow without redoing the cross product calculation
func IsColinearOrLeft ¶
IsColinearOrLeft is equivalent to calling IsColinear || IsLeft without redoing the cross product calculation.
func IsColinearOrRight ¶
IsColinearOrRight is equivalent to calling IsColinear || IsRight without redoing the cross product calculation
func IsRightOf ¶
IsRightOf is equivalent to !IsLeftOf, except that both IsRightOf and IsLeftOf return false for Cross2D() == 0
func VertCross2D ¶
VertCross2D returns the cross product corrected for verticality-- b and c are organized such that left/rightness checks can be made.
func VerticalCompare ¶
func VerticalCompare(dp D2, e Spanning) search.CompareResult
VerticalCompare returns a search result representing whether this point is above equal or below the query edge.
Types ¶
type D2 ¶
D2 Values are dimensional values with at least X and Y values. Consider whether this should be "TwoD"
type Dimensional ¶
type Dimensional interface { Val(int) float64 Set(int, float64) Dimensional // D returns the number of dimensions // a value has. D() int Eq(Dimensional) bool }
Dimensional values can be queried at a given dimension for a positional value
type FullEdge ¶
type FullEdge [2]Point
FullEdge is (eventually) a span across two arbitrary points
func NewFullEdge ¶
NewFullEdge type casts interfaces to points to hold in a FullEdge
func (FullEdge) At ¶
func (fe FullEdge) At(i int) Dimensional
At returns the value at a given index on this edge.
func (FullEdge) BothPoints ¶
func (FullEdge) High ¶
func (fe FullEdge) High(d int) Dimensional
High returns whatever value is higher at dimension d on this edge
func (FullEdge) Low ¶
func (fe FullEdge) Low(d int) Dimensional
Low returns whatever value is lower at dimension d on this edge
func (FullEdge) Set ¶
func (fe FullEdge) Set(i int, d Dimensional) Spanning
Set returns this edge with a value at i changed to d
func (FullEdge) Slope ¶
Slope returns the slope on this FullEdge. This slope will always have a positive X value.
type Point ¶
A Point is just a N-dimensional point.
func (Point) Cross2D ¶
Cross2D performs the Cross Product on the three points, in a two-dimensional context.
func (Point) Dot2D ¶
Dot2D performs Dot multiplication on the two points, in a two-dimensional context.
func (Point) Eq ¶
func (dp Point) Eq(p2 Dimensional) bool
Eq returns whether two points are equivalent.
func (Point) Greater2D ¶
Greater2D reports the higher point by y value, or by x value given equal y values. If the two points are equal the latter point is returned.
func (Point) Lesser2D ¶
Lesser2D reports the lower point by y value, or by x value given equal y values. If the two points are equal the latter point is returned.
func (Point) Magnitude2D ¶
Magnitude2D reports the magnitude of the point interpreted as a vector in a two-dimensional context.
type Span ¶
type Span struct {
FullEdge
}
A Span represents n-dimensions of span from one point to another for however many dimensions a point has
func NewSpan ¶
func NewSpan(ds ...Dimensional) Span
NewSpan returns a span with its values set to appropriate infinities
func (Span) Expand ¶
func (sp Span) Expand(ps ...Dimensional) Span
Expand on a Span will reduce or increase a span's min and max values if the input points falls outside of the span on any dimension
type Spanning ¶
type Spanning interface { D() int Len() int Set(int, Dimensional) Spanning At(int) Dimensional Low(int) Dimensional High(int) Dimensional Eq(Spanning) bool }
Spanning types are a length of dimensionals.