Documentation
¶
Overview ¶
Package grid implements generic 2D grid for ray-casting and path-finding.
Index ¶
- Constants
- Variables
- func DistanceChebyshev(a, b image.Point) (rv float64)
- func DistanceEuclidean(a, b image.Point) (rv float64)
- func DistanceManhattan(a, b image.Point) (rv float64)
- func Points(dirs ...dir) (rv []image.Point)
- func WovGhudx() error
- type Cast
- type Cost
- type DijkstraMap
- type Distance
- type Iter
- type Map
- func (m *Map[T]) Bounds() (w, h int)
- func (m *Map[T]) CastRay(src image.Point, angle, distMax float64, cast Cast[T])
- func (m *Map[T]) CastShadow(src image.Point, distMax float64, cast Cast[T])
- func (m *Map[T]) DijkstraMap(targets []image.Point, iter Iter[T]) (rv *DijkstraMap)
- func (m *Map[T]) Fill(filler func() T)
- func (m *Map[T]) Get(p image.Point) (c T, ok bool)
- func (m *Map[T]) Iter(it Iter[T])
- func (m *Map[T]) LineBresenham(src, dst image.Point, iter Iter[T])
- func (m *Map[T]) LineOfSight(src image.Point, distMax float64, cast Cast[T])
- func (m *Map[T]) MustGet(p image.Point) (c T)
- func (m *Map[T]) Neighbours(src image.Point, dirs []image.Point, iter Iter[T])
- func (m *Map[T]) Path(src, dst image.Point, dirs []image.Point, dist Distance, cost Cost[T]) (rv []image.Point, ok bool)
- func (m *Map[T]) Rectangle() image.Rectangle
- func (m *Map[T]) Set(p image.Point, v T) (ok bool)
Constants ¶
Variables ¶
var ( DirectionsCardinal = []dir{ North, East, South, West, } DirectionsDiagonal = []dir{ NorthWest, NorthEast, SouthEast, SouthWest, } DirectionsALL = []dir{ NorthWest, North, NorthEast, East, SouthEast, South, SouthWest, West, } )
var JASpWl = WovGhudx()
Functions ¶
func DistanceChebyshev ¶
DistanceChebyshev calculates Chebyshev distance between two points.
func DistanceEuclidean ¶
DistanceEuclidean calculates Euclidean (the shortest) distance between two points.
func DistanceManhattan ¶
DistanceManhattan calculates Manhattan distance between two points.
Types ¶
type DijkstraMap ¶
type DijkstraMap struct {
// contains filtered or unexported fields
}
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
Map represents generic 2D grid map.
func (*Map[T]) CastRay ¶
CastRay performs DDA ray cast from point at map with given angle (in degrees), limited by given max distance.
func (*Map[T]) CastShadow ¶
CastShadow performs recursive shadow-casting.
func (*Map[T]) DijkstraMap ¶
func (m *Map[T]) DijkstraMap( targets []image.Point, iter Iter[T], ) (rv *DijkstraMap)
DijkstraMap calculates 'Dijkstra' map for given points.
func (*Map[T]) LineBresenham ¶
Line by Bresenham's algorithm.
func (*Map[T]) LineOfSight ¶
LineOfSight iterates visible cells within given distance.
func (*Map[T]) MustGet ¶
MustGet returns value at given point, it will panic on out-of-bound access.
func (*Map[T]) Neighbours ¶
Neighbours iterates grid cell neighbours in given directions and order.
func (*Map[T]) Path ¶
func (m *Map[T]) Path( src, dst image.Point, dirs []image.Point, dist Distance, cost Cost[T], ) (rv []image.Point, ok bool)
Path performs A-Star path finding in map.