Added langext/coords && CompareArr[T]

This commit is contained in:
Mike Schwörer 2022-10-27 18:04:20 +02:00
parent c223e2f0fa
commit 21ae9c70d2
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 42 additions and 0 deletions

View File

@ -30,3 +30,34 @@ func CompareIntArr(arr1 []int, arr2 []int) bool {
return false return false
} }
func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool {
for i := 0; i < len(arr1) || i < len(arr2); i++ {
if i < len(arr1) && i < len(arr2) {
if arr1[i] < arr2[i] {
return true
} else if arr1[i] > arr2[i] {
return false
} else {
continue
}
}
if i < len(arr1) {
return true
} else { // if i < len(arr2)
return false
}
}
return false
}

11
langext/coords.go Normal file
View File

@ -0,0 +1,11 @@
package langext
import "math"
func DegToRad(deg float64) float64 {
return deg * (math.Pi / 180.0)
}
func RadToDeg(rad float64) float64 {
return rad / (math.Pi * 180.0)
}