Documentation
¶
Overview ¶
Package spatial contain types about accessing and storing spatial data.
Index ¶
- Variables
- type DiscreteMap2D
- func (d *DiscreteMap2D[T]) GetDataIndex(pos DiscretePos2D) int
- func (d *DiscreteMap2D[T]) GetValue(dim int, pos DiscretePos2D) T
- func (d *DiscreteMap2D[T]) IsPositionInbounds(p DiscretePos2D) bool
- func (d *DiscreteMap2D[T]) SetValue(dim int, pos DiscretePos2D, value T)
- func (d DiscreteMap2D[T]) String() string
- type DiscretePos2D
Constants ¶
This section is empty.
Variables ¶
var ( N = DiscretePos2D{0, 1} NE = DiscretePos2D{1, 1} E = DiscretePos2D{1, 0} SE = DiscretePos2D{1, -1} S = DiscretePos2D{0, -1} SW = DiscretePos2D{-1, -1} W = DiscretePos2D{-1, 0} NW = DiscretePos2D{-1, 1} )
Functions ¶
This section is empty.
Types ¶
type DiscreteMap2D ¶
DiscreteMap2D can be used for storing 2d data with multiple dimensions in a integer coordinate system.
The origin is top left of the map.
func NewDiscreteMap2D ¶
func NewDiscreteMap2D[T any](width, height, dimension int) DiscreteMap2D[T]
NewDiscreteMap2D creates a new DiscreteMap2D with given width, height and dimension
func NewDiscreteMap2DFromLines ¶
func NewDiscreteMap2DFromLines[T any](dimension int, lines []string, transformFunc func(r rune, pos DiscretePos2D) T) DiscreteMap2D[T]
NewDiscreteMap2DFromLines creates DiscreteMap2D with width and height from the input lines it is assumed all linesare the same length first dimension is filled from lines in combination with the transformFunc data type.
func (*DiscreteMap2D[T]) GetDataIndex ¶
func (d *DiscreteMap2D[T]) GetDataIndex(pos DiscretePos2D) int
GetDataIndex gets the index to read data in the DiscreteMap2D position x is used for width, y for height
func (*DiscreteMap2D[T]) GetValue ¶
func (d *DiscreteMap2D[T]) GetValue(dim int, pos DiscretePos2D) T
GetValue the value of position in dimension. The positions x is width, y is height.
func (*DiscreteMap2D[T]) IsPositionInbounds ¶
func (d *DiscreteMap2D[T]) IsPositionInbounds(p DiscretePos2D) bool
func (*DiscreteMap2D[T]) SetValue ¶
func (d *DiscreteMap2D[T]) SetValue(dim int, pos DiscretePos2D, value T)
SetValue sets a value of a position in the dimension
func (DiscreteMap2D[T]) String ¶
func (d DiscreteMap2D[T]) String() string
type DiscretePos2D ¶
DiscretePos2D is used to access values in the DiscreteMap2D. The x values are used for width, y for height.
func GetAdjacentPositions ¶
func GetAdjacentPositions(pos DiscretePos2D) []DiscretePos2D
GetAdjacentPositions returns the adjacent positions. in clockwise order starting from North
func GetBorderPositions ¶
func GetBorderPositions(pos DiscretePos2D) []DiscretePos2D
GetBorderPositions returns the four bordering neighbour positions in order: x+1, x-1, y+1, y-1 East, West, North, South
func (DiscretePos2D) Add ¶
func (p DiscretePos2D) Add(p2 DiscretePos2D) DiscretePos2D
Add returns the added result as a new position