Implement current wind direction and rover wind movement

This commit is contained in:
Marc Di Luzio 2020-07-22 23:36:13 +01:00
parent c94ac68f44
commit c89c5f6e74
7 changed files with 174 additions and 119 deletions

View file

@ -107,3 +107,13 @@ func BearingToVector(b roveapi.Bearing) Vector {
return Vector{}
}
// Dot returns the dot product of two vectors
func Dot(a Vector, b Vector) int {
return a.X*b.X + a.Y*b.Y
}
// AngleCos returns the cosine of the angle between two vectors
func AngleCos(a Vector, b Vector) float64 {
return float64(Dot(a, b)) / a.Length() * b.Length()
}