|
@@ -7,8 +7,8 @@ import (
|
|
|
|
|
|
// A Point 2D
|
|
// A Point 2D
|
|
type Point struct {
|
|
type Point struct {
|
|
- X int64 // X Axis (Horizontal)
|
|
|
|
- Y int64 // Y Axis (Vertical)
|
|
|
|
|
|
+ X int // X Axis (Horizontal)
|
|
|
|
+ Y int // Y Axis (Vertical)
|
|
}
|
|
}
|
|
|
|
|
|
// Creates a new point at (0, 0)
|
|
// Creates a new point at (0, 0)
|
|
@@ -17,7 +17,7 @@ func NewPoint() *Point {
|
|
}
|
|
}
|
|
|
|
|
|
// Creates a new point given 1-2 integers (more integers are ignored)
|
|
// Creates a new point given 1-2 integers (more integers are ignored)
|
|
-func AsPoint(to ...int64) *Point {
|
|
|
|
|
|
+func AsPoint(to ...int) *Point {
|
|
var p *Point = &Point{}
|
|
var p *Point = &Point{}
|
|
if len(to) == 1 {
|
|
if len(to) == 1 {
|
|
p.X = to[0]
|
|
p.X = to[0]
|
|
@@ -30,7 +30,7 @@ func AsPoint(to ...int64) *Point {
|
|
}
|
|
}
|
|
|
|
|
|
// Assignment by 1-2 integers (more integers are ignored)
|
|
// Assignment by 1-2 integers (more integers are ignored)
|
|
-func (p *Point) Set(to ...int64) *Point {
|
|
|
|
|
|
+func (p *Point) Set(to ...int) *Point {
|
|
if len(to) == 1 {
|
|
if len(to) == 1 {
|
|
p.X = to[0]
|
|
p.X = to[0]
|
|
p.Y = to[0]
|
|
p.Y = to[0]
|
|
@@ -49,7 +49,7 @@ func (p *Point) SetTo(o *Point) *Point {
|
|
}
|
|
}
|
|
|
|
|
|
// Translate by 1-2 integers (more integers are ignored)
|
|
// Translate by 1-2 integers (more integers are ignored)
|
|
-func (p *Point) Move(by ...int64) *Point {
|
|
|
|
|
|
+func (p *Point) Move(by ...int) *Point {
|
|
if len(by) == 1 {
|
|
if len(by) == 1 {
|
|
p.X += by[0]
|
|
p.X += by[0]
|
|
p.Y += by[0]
|
|
p.Y += by[0]
|
|
@@ -108,17 +108,17 @@ func (p *Point) IsZero() bool {
|
|
}
|
|
}
|
|
|
|
|
|
// Compares if the Point's X is the same as given X axis
|
|
// Compares if the Point's X is the same as given X axis
|
|
-func (p *Point) IsX(x int64) bool {
|
|
|
|
|
|
+func (p *Point) IsX(x int) bool {
|
|
return p.X == x
|
|
return p.X == x
|
|
}
|
|
}
|
|
|
|
|
|
// Compares if the Point's Y is the same as given Y axis
|
|
// Compares if the Point's Y is the same as given Y axis
|
|
-func (p *Point) IsY(y int64) bool {
|
|
|
|
|
|
+func (p *Point) IsY(y int) bool {
|
|
return p.Y == y
|
|
return p.Y == y
|
|
}
|
|
}
|
|
|
|
|
|
// Compares if the Point is equal to the 1-2 integers (more integers are ignored)
|
|
// Compares if the Point is equal to the 1-2 integers (more integers are ignored)
|
|
-func (p *Point) Equal(to ...int64) bool {
|
|
|
|
|
|
+func (p *Point) Equal(to ...int) bool {
|
|
if len(to) == 1 {
|
|
if len(to) == 1 {
|
|
return p.X == to[0] && p.Y == to[0]
|
|
return p.X == to[0] && p.Y == to[0]
|
|
} else if len(to) >= 2 {
|
|
} else if len(to) >= 2 {
|
|
@@ -133,7 +133,7 @@ func (p *Point) EqualTo(o *Point) bool {
|
|
}
|
|
}
|
|
|
|
|
|
// Compares the Point against 1-2 integers (more integers are ignored)
|
|
// Compares the Point against 1-2 integers (more integers are ignored)
|
|
-func (p *Point) Less(than ...int64) bool {
|
|
|
|
|
|
+func (p *Point) Less(than ...int) bool {
|
|
if len(than) == 1 {
|
|
if len(than) == 1 {
|
|
return p.X <= than[0] && p.Y <= than[0]
|
|
return p.X <= than[0] && p.Y <= than[0]
|
|
} else if len(than) >= 2 {
|
|
} else if len(than) >= 2 {
|
|
@@ -148,7 +148,7 @@ func (p *Point) LessThan(o *Point) bool {
|
|
}
|
|
}
|
|
|
|
|
|
// Compares the Point against 1-2 integers (more integers are ignored)
|
|
// Compares the Point against 1-2 integers (more integers are ignored)
|
|
-func (p *Point) Greater(than ...int64) bool {
|
|
|
|
|
|
+func (p *Point) Greater(than ...int) bool {
|
|
if len(than) == 1 {
|
|
if len(than) == 1 {
|
|
return p.X >= than[0] && p.Y >= than[0]
|
|
return p.X >= than[0] && p.Y >= than[0]
|
|
} else if len(than) >= 2 {
|
|
} else if len(than) >= 2 {
|
|
@@ -180,7 +180,7 @@ func (p *Point) Within(topLeft, botRight *Point) bool {
|
|
}
|
|
}
|
|
|
|
|
|
// The distance from the Point to the assumed location
|
|
// The distance from the Point to the assumed location
|
|
-func (p *Point) Distance(x, y int64) int {
|
|
|
|
|
|
+func (p *Point) Distance(x, y int) int {
|
|
a := float64(p.X - x)
|
|
a := float64(p.X - x)
|
|
b := float64(p.Y - y)
|
|
b := float64(p.Y - y)
|
|
return int(math.Max(math.Abs(a), math.Abs(b)))
|
|
return int(math.Max(math.Abs(a), math.Abs(b)))
|