plane

package
v0.0.0-...-e03219f Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DirectionToVector = map[Direction]Vector{
	North:     {0, -1},
	NorthEast: {1, -1},
	East:      {1, 0},
	SouthEast: {1, 1},
	South:     {0, 1},
	SouthWest: {-1, 1},
	West:      {-1, 0},
	NorthWest: {-1, -1},
}

7 0 1 6 2 5 4 3

Functions

func Draw

func Draw(parts map[byte][]Vector, limit Vector) string

func ManhattanMetric

func ManhattanMetric(v, u Vector) int

Types

type Direction

type Direction int
const (
	North     Direction = 0
	NorthEast Direction = 1
	East      Direction = 2
	SouthEast Direction = 3
	South     Direction = 4
	SouthWest Direction = 5
	West      Direction = 6
	NorthWest Direction = 7
)

func (Direction) Opposite

func (d Direction) Opposite() Direction

func (Direction) Orthogonal

func (d Direction) Orthogonal() bool

func (Direction) String

func (d Direction) String() string

func (Direction) Turn

func (d Direction) Turn(degrees int) Direction

Turn expects degrees to be multiple of 45. +ve means clockwise, -ve anti-clockwise

type Metric

type Metric func(Vector, Vector) int

type Vector

type Vector struct {
	X, Y int
}

func (Vector) Add

func (v Vector) Add(u Vector) Vector

func (Vector) AddDirection

func (v Vector) AddDirection(d Direction) Vector

func (Vector) Minus

func (v Vector) Minus(u Vector) Vector

func (Vector) MinusDirection

func (v Vector) MinusDirection(d Direction) Vector

func (Vector) Neighbours

func (v Vector) Neighbours() map[Direction]Vector

func (Vector) OrthogonalNeighbours

func (v Vector) OrthogonalNeighbours() map[Direction]Vector

func (Vector) Within

func (v Vector) Within(limit Vector) bool

Jump to

Keyboard shortcuts

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