Written the ImageWriter
This commit is contained in:
23
maze/maze.go
23
maze/maze.go
@ -1,8 +1,31 @@
|
||||
package maze
|
||||
|
||||
import "math"
|
||||
|
||||
type Coordinates struct {
|
||||
X, Y int
|
||||
}
|
||||
|
||||
func (c Coordinates) Distance(o Coordinates) float64 {
|
||||
x, y := float64(o.X-c.X), float64(o.Y-c.Y)
|
||||
|
||||
if y == 0 {
|
||||
if x < 0 {
|
||||
return -x
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
if x == 0 {
|
||||
if y < 0 {
|
||||
return -y
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
return math.Sqrt(x*x + y*y)
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
Coords Coordinates
|
||||
Up, Down *Node
|
||||
|
Reference in New Issue
Block a user