geom

package
v0.0.0-...-67a39db Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Inf is shorthand for math.MaxFloat64
	Inf = math.MaxFloat64
	// NegInf is shorthand for math.MaxFloat64 * -1
	NegInf = -math.MaxFloat64
)
View Source
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
)
View Source
const (
	// POINT_DIM is the number of dimensions a point holds.
	POINT_DIM = 3
)

Variables

This section is empty.

Functions

func Cross2D

func Cross2D(a, b, c D2) float64

Cross2D preforms the cross product on three points in two dimensions.

func Distance2D

func Distance2D(p1, p2 D2) float64

func Dot2D

func Dot2D(p1, p2 D2) float64

Dot2D returns the dot product of two 2d elements.

func F64eq

func F64eq(f1, f2 float64) bool

F64eq returns whether two input float64s have a lesser difference than epsilon.

func HzCross2D

func HzCross2D(a, b, c D2) float64

HzCross2D is equivalent to VertCross2D for horizontal queries.

func IsAbove

func IsAbove(a, b, c D2) bool

IsAbove returns whether a is above the line segment formed by (b->c)

func IsBelow

func IsBelow(a, b, c D2) bool

IsBelow is equivalent to !IsAbove && !IsColinear

func IsColinear

func IsColinear(a, b, c D2) bool

IsColinear returns whether the cross product reports 0.

func IsColinearOrAbove

func IsColinearOrAbove(a, b, c D2) bool

IsColinearOrAbove is equivalent to calling IsColinear || IsAbove without redoing the cross product calculation.

func IsColinearOrBelow

func IsColinearOrBelow(a, b, c D2) bool

IsColinearOrBelow is equivalent to calling IsColinear || IsBelow without redoing the cross product calculation

func IsColinearOrLeft

func IsColinearOrLeft(a, b, c D2) bool

IsColinearOrLeft is equivalent to calling IsColinear || IsLeft without redoing the cross product calculation.

func IsColinearOrRight

func IsColinearOrRight(a, b, c D2) bool

IsColinearOrRight is equivalent to calling IsColinear || IsRight without redoing the cross product calculation

func IsLeftOf

func IsLeftOf(a, b, c D2) bool

IsLeftOf returns whether a is to the left of the line segment formed by (b->c)

func IsRightOf

func IsRightOf(a, b, c D2) bool

IsRightOf is equivalent to !IsLeftOf, except that both IsRightOf and IsLeftOf return false for Cross2D() == 0

func Round

func Round(num float64) int

Round converts a float64 to an integer.

func ToFixed

func ToFixed(num float64, precision int) float64

ToFixed converts a float64 to a float64 with a limited number of decimal places

func VertCross2D

func VertCross2D(a, b, c D2) float64

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 D1

type D1 interface {
	Dimensional
	X() float64
}

D1 Values are just xes.

type D2

type D2 interface {
	D1
	Y() float64
}

D2 Values are dimensional values with at least X and Y values. Consider whether this should be "TwoD"

func Greater2D

func Greater2D(p1, p2 D2) D2

Greater2D acts as Lesser2D, but reversed.

func Lesser2D

func Lesser2D(p1, p2 D2) D2

Lesser2D returns which D2 is lexiographically lesser, preferring y to x.

type D3

type D3 interface {
	D2
	Z() float64
}

D3 values have Z values on top of D2.

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

func NewFullEdge(p1, p2 D3) FullEdge

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 (fe FullEdge) BothPoints() (D3, D3)

func (FullEdge) Bottom

func (fe FullEdge) Bottom() D3

Bottom renames Low(1)

func (FullEdge) D

func (fe FullEdge) D() int

D returns the number of dimensions in this edge.

func (FullEdge) Eq

func (fe FullEdge) Eq(s Spanning) bool

Eq returns whether this edge is equivalent to another spanning type

func (FullEdge) High

func (fe FullEdge) High(d int) Dimensional

High returns whatever value is higher at dimension d on this edge

func (FullEdge) Inner

func (fe FullEdge) Inner() D3

Inner renames High(1)

func (FullEdge) Left

func (fe FullEdge) Left() D3

Left renames Low(0)

func (FullEdge) Len

func (fe FullEdge) Len() int

Len returns the number of elements on this edge (2)

func (FullEdge) Low

func (fe FullEdge) Low(d int) Dimensional

Low returns whatever value is lower at dimension d on this edge

func (FullEdge) Outer

func (fe FullEdge) Outer() D3

Outer renames Low(2)

func (FullEdge) PointAt

func (fe FullEdge) PointAt(d int, v float64) (Point, error)

PointAt returns the value along this edge at v in the dth dimension.

func (FullEdge) Right

func (fe FullEdge) Right() D3

Right renames High(0)

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

func (fe FullEdge) Slope() float64

Slope returns the slope on this FullEdge. This slope will always have a positive X value.

func (FullEdge) SubEdge

func (fe FullEdge) SubEdge(d int, v1, v2 float64) (FullEdge, error)

SubEdge returns the portion of this edge from pointAt(d,v1) to pointAt(d,v2)

func (FullEdge) Top

func (fe FullEdge) Top() D3

Top renames High(1)

type Point

type Point [POINT_DIM]float64

A Point is just a N-dimensional point.

func NewPoint

func NewPoint(x, y, z float64) Point

NewPoint returns a Point initialized at the given position

func (Point) Bounds

func (dp Point) Bounds() S3

Bounds on a Point will return the point itself.

func (Point) Cross2D

func (dp Point) Cross2D(p2, p3 D2) float64

Cross2D performs the Cross Product on the three points, in a two-dimensional context.

func (Point) D

func (dp Point) D() int

D returns the number of dimensions supported by a point.

func (Point) Dot2D

func (dp Point) Dot2D(p2 D2) float64

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

func (dp Point) Greater2D(p2 D2) D2

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

func (dp Point) Lesser2D(p2 D2) D2

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

func (dp Point) Magnitude2D() float64

Magnitude2D reports the magnitude of the point interpreted as a vector in a two-dimensional context.

func (Point) Mid2D

func (dp Point) Mid2D(p2 D2) Point

Mid2D returns the point in the middle of this point and p2.

func (Point) Set

func (dp Point) Set(i int, v float64) Dimensional

Set sets the value at the given dimension on the point.

func (Point) String

func (dp Point) String() string

String converts dp into a string.

func (Point) Val

func (dp Point) Val(d int) float64

Val is equivalent to array access on a point.

func (Point) X

func (dp Point) X() float64

X : Get the value of this point on the x axis

func (Point) Y

func (dp Point) Y() float64

Y : Get the value of this point on the y axis

func (Point) Z

func (dp Point) Z() float64

Z : Get the value of this point on the z axis

type S1

type S1 interface {
	Spanning
	Left() D3
	Right() D3
}

S1 identifies spans whose points are 1d.

type S2

type S2 interface {
	S1
	Top() D3
	Bottom() D3
}

S2 identifies spans whose points are 2d.

type S3

type S3 interface {
	S2
	Inner() D3
	Outer() D3
}

S3 identifies spans whose points are 3d

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) Bottom

func (sp Span) Bottom() D3

Bottom returns Span Min

func (Span) Diff

func (sp Span) Diff() D3

Diff returns the distance between sp.Min and sp.Max.

func (Span) Eq

func (sp Span) Eq(s Spanning) bool

Eq returns whether Span is equivalent to the given spanning type

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

func (Span) Greater

func (sp Span) Greater(d int) Dimensional

Greater returns Span Max

func (Span) High

func (sp Span) High(i int) Dimensional

High returns SPAN_MAX

func (Span) Inner

func (sp Span) Inner() D3

Inner returns Span Max

func (Span) Left

func (sp Span) Left() D3

Left returns Span Min

func (Span) Lesser

func (sp Span) Lesser(d int) Dimensional

Lesser returns Span Min

func (Span) Low

func (sp Span) Low(i int) Dimensional

Low returns SPAN_MIN

func (Span) Outer

func (sp Span) Outer() D3

Outer returns Span Min

func (Span) Right

func (sp Span) Right() D3

Right returns Span Max

func (Span) Set

func (sp Span) Set(i int, d Dimensional) Spanning

Set , which you should probably not use on a Span, sets the value of one of span's min or max to something which will no longer necessarily be the min or max of the points the span has been exposed to. Consider using a FullEdge.

func (Span) Top

func (sp Span) Top() D3

Top returns Span Max

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.

Jump to

Keyboard shortcuts

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