Documentation ¶
Index ¶
- Variables
- func Point2dDistance(p, q Point2d) float64
- type Bound
- func (b Bound) Bottom() float64
- func (b Bound) Bound() Bound
- func (b Bound) Center() Point2d
- func (b Bound) Contains(point Point2d) bool
- func (b Bound) Equal(c Bound) bool
- func (b Bound) Extend(point Point2d) Bound
- func (b Bound) Intersects(bound Bound) bool
- func (b Bound) IsEmpty() bool
- func (b Bound) IsZero() bool
- func (b Bound) Left() float64
- func (b Bound) LeftTop() Point2d
- func (b Bound) Pad(d float64) Bound
- func (b Bound) Right() float64
- func (b Bound) RightBottom() Point2d
- func (b Bound) Top() float64
- func (b Bound) Union(other Bound) Bound
- type LinearSlice
- func (s LinearSlice[T]) Contains(p T) bool
- func (s LinearSlice[T]) InRange(p T, r float64) []T
- func (s LinearSlice[T]) InRangeCount(p T, r float64) int
- func (s *LinearSlice[T]) Insert(p T)
- func (s LinearSlice[T]) Nearest(p T) T
- func (s LinearSlice[T]) NearestN(p T, n int) ([]T, error)
- func (s *LinearSlice[T]) Remove(p T)
- type Point2d
- type Quadtree
- type Spatial
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadNumberOfPoints = errors.New("asked for too many points or < 0") ErrPointOutsideOfBounds = errors.New("point outside of bounds") )
Functions ¶
func Point2dDistance ¶
Types ¶
type Bound ¶
type Bound struct {
Min, Max Point2d
}
Bound is a copy of https://github.com/paulmach/orb/blob/215f32c132d13f906979dbb36bd24c1e0511b6d2/bound.go#L12
func (Bound) Contains ¶
Contains determines if the point is within the bound. Points on the boundary are considered within.
func (Bound) Intersects ¶
Intersects determines if two bounds intersect. Returns true if they are touching.
func (Bound) IsEmpty ¶
IsEmpty returns true if it contains zero area or if it's in some malformed negative state where the left point is larger than the right. This can be caused by padding too much negative.
func (Bound) RightBottom ¶
RightBottom return the lower right point of the bound.
type LinearSlice ¶
type LinearSlice[T comparable] struct { // contains filtered or unexported fields }
LinearSlice is meant for testing the other types. It is optimized for testing ease
func NewLinearSlice ¶
func NewLinearSlice[T comparable](points []T, distance_func func(T, T) float64) LinearSlice[T]
func (LinearSlice[T]) Contains ¶
func (s LinearSlice[T]) Contains(p T) bool
Contains returns true if p is in s.
func (LinearSlice[T]) InRange ¶
func (s LinearSlice[T]) InRange(p T, r float64) []T
InRange returns all points in s within range of p.
func (LinearSlice[T]) InRangeCount ¶
func (s LinearSlice[T]) InRangeCount(p T, r float64) int
InRangeCount counts all the points in `s` that are closer to `p` than `r`
func (LinearSlice[T]) Nearest ¶
func (s LinearSlice[T]) Nearest(p T) T
Nearest returns the nearest point in s to p.
func (LinearSlice[T]) NearestN ¶
func (s LinearSlice[T]) NearestN(p T, n int) ([]T, error)
NearestN returns the nearest n points in s to p. If `n > len(s)`, returns an error
func (*LinearSlice[T]) Remove ¶
func (s *LinearSlice[T]) Remove(p T)
Remove removes the first instance of p from s. If it is not found, nothing happens
type Quadtree ¶
type Quadtree[T any] struct { // contains filtered or unexported fields }
Quadtree is based heavily off of https://github.com/paulmach/orb/blob/215f32c132d13f906979dbb36bd24c1e0511b6d2/quadtree/quadtree.go