支持更多的计算函数

This commit is contained in:
kercylan98
2023-06-19 14:15:08 +08:00
parent 261b14e789
commit caa1512e1c
5 changed files with 165 additions and 2 deletions
+11
View File
@@ -139,3 +139,14 @@ func CalculateNewCoordinate[V generic.SignedNumber](x, y, angle, distance V) (ne
return newX, newY
}
// CalcAngleDifference 计算两个角度之间的最小角度差
func CalcAngleDifference[V generic.Number](angleA, angleB V) V {
pi := math.Pi
t := angleA - angleB
a := t + V(pi)
b := V(pi) * 2
t = V(math.Floor(float64(a/b))) * b
t -= pi
return t
}