Move vector into maths package

This commit is contained in:
Marc Di Luzio 2020-07-10 18:22:59 +01:00
parent 97d3be000b
commit 5b1fe61097
11 changed files with 131 additions and 134 deletions

View file

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/mdiluz/rove/pkg/vector"
"github.com/mdiluz/rove/pkg/maths"
)
// Bearing describes a compass direction
@ -67,7 +67,7 @@ func FromString(s string) (Bearing, error) {
return -1, fmt.Errorf("unknown bearing: %s", s)
}
var bearingVectors = []vector.Vector{
var bearingVectors = []maths.Vector{
{X: 0, Y: 1}, // N
{X: 1, Y: 1}, // NE
{X: 1, Y: 0}, // E
@ -79,6 +79,6 @@ var bearingVectors = []vector.Vector{
}
// Vector converts a Direction to a Vector
func (d Bearing) Vector() vector.Vector {
func (d Bearing) Vector() maths.Vector {
return bearingVectors[d]
}

View file

@ -3,7 +3,7 @@ package bearing
import (
"testing"
"github.com/mdiluz/rove/pkg/vector"
"github.com/mdiluz/rove/pkg/maths"
"github.com/stretchr/testify/assert"
)
@ -12,7 +12,7 @@ func TestDirection(t *testing.T) {
assert.Equal(t, "North", dir.String())
assert.Equal(t, "N", dir.ShortString())
assert.Equal(t, vector.Vector{X: 0, Y: 1}, dir.Vector())
assert.Equal(t, maths.Vector{X: 0, Y: 1}, dir.Vector())
dir, err := FromString("N")
assert.NoError(t, err)