From 21ae9c70d28b29b0f7ce681d750595ed4e3c9bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Thu, 27 Oct 2022 18:04:20 +0200 Subject: [PATCH] Added langext/coords && CompareArr[T] --- langext/compare.go | 31 +++++++++++++++++++++++++++++++ langext/coords.go | 11 +++++++++++ 2 files changed, 42 insertions(+) create mode 100644 langext/coords.go diff --git a/langext/compare.go b/langext/compare.go index ac35b85..5573f5d 100644 --- a/langext/compare.go +++ b/langext/compare.go @@ -30,3 +30,34 @@ func CompareIntArr(arr1 []int, arr2 []int) bool { 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 +} diff --git a/langext/coords.go b/langext/coords.go new file mode 100644 index 0000000..38ed6d7 --- /dev/null +++ b/langext/coords.go @@ -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) +}