From 52494022f65ca73766a4991ff1d1bcc6cabbdad5 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sat, 9 May 2020 08:03:44 +0200 Subject: [PATCH] Added Pow{,32}. --- math.go | 256 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 133 insertions(+), 123 deletions(-) diff --git a/math.go b/math.go index 5b8216e..5d820a2 100644 --- a/math.go +++ b/math.go @@ -1,123 +1,133 @@ -package geom - -import "math" - -// Abs returns the absolute value. -func Abs(f float64) float64 { - return math.Abs(f) -} - -// Abs32 returns the absolute value. -func Abs32(f float32) float32 { - return float32(Abs(float64(f))) -} - -// Atan returns the arctangent of f. -func Atan(f float64) float64 { - return math.Atan(f) -} - -// Atan32 returns the arctangent of f. -func Atan32(f float32) float32 { - return float32(math.Atan(float64(f))) -} - -// Cos returns the cosine of f. -func Cos(f float64) float64 { - return math.Cos(f) -} - -// Cos32 returns the cosine of f. -func Cos32(f float32) float32 { - return float32(math.Cos(float64(f))) -} - -// IsNaN checks if the floating point number is not a number. -func IsNaN(f float64) bool { - return f != f -} - -// IsNaN32 checks if the floating point number is not a number. -func IsNaN32(f float32) bool { - return f != f -} - -// Max the maximum of the two values. -func Max(a, b float64) float64 { - return math.Max(a, b) -} - -// Max32 the maximum of the two values. -func Max32(a, b float32) float32 { - return float32(math.Max(float64(a), float64(b))) -} - -// Min the minimum of the two values. -func Min(a, b float64) float64 { - return math.Min(a, b) -} - -// Min32 the minimum of the two values. -func Min32(a, b float32) float32 { - return float32(math.Min(float64(a), float64(b))) -} - -// NaN returns not a floating point number. -func NaN() float64 { - return math.NaN() -} - -// NaN32 returns not a floating point number. -func NaN32() float32 { - return float32(NaN()) -} - -// Round rounds to the nearest integer. -func Round(f float64) float64 { - return math.Round(f) -} - -// Round32 rounds to the nearest integer. -func Round32(f float32) float32 { - return float32(math.Round(float64(f))) -} - -// Sin returns the sine of f. -func Sin(f float64) float64 { - return math.Sin(f) -} - -// Sin32 returns the sine of f. -func Sin32(f float32) float32 { - return float32(math.Sin(float64(f))) -} - -// Sq returns the squared value of f. -func Sq(f float64) float64 { - return f * f -} - -// Sq32 returns the squared value of f. -func Sq32(f float32) float32 { - return f * f -} - -// Sqrt the square root of the value. -func Sqrt(f float64) float64 { - return math.Sqrt(f) -} - -// Sqrt32 the square root of the value. -func Sqrt32(f float32) float32 { - return float32(Sqrt(float64(f))) -} - -// Tan returns the tangent of f. -func Tan(f float64) float64 { - return math.Tan(f) -} - -// Tan32 returns the tangent of f. -func Tan32(f float32) float32 { - return float32(math.Tan(float64(f))) -} +package geom + +import "math" + +// Abs returns the absolute value. +func Abs(f float64) float64 { + return math.Abs(f) +} + +// Abs32 returns the absolute value. +func Abs32(f float32) float32 { + return float32(Abs(float64(f))) +} + +// Atan returns the arctangent of f. +func Atan(f float64) float64 { + return math.Atan(f) +} + +// Atan32 returns the arctangent of f. +func Atan32(f float32) float32 { + return float32(math.Atan(float64(f))) +} + +// Cos returns the cosine of f. +func Cos(f float64) float64 { + return math.Cos(f) +} + +// Cos32 returns the cosine of f. +func Cos32(f float32) float32 { + return float32(math.Cos(float64(f))) +} + +// IsNaN checks if the floating point number is not a number. +func IsNaN(f float64) bool { + return f != f +} + +// IsNaN32 checks if the floating point number is not a number. +func IsNaN32(f float32) bool { + return f != f +} + +// Max the maximum of the two values. +func Max(a, b float64) float64 { + return math.Max(a, b) +} + +// Max32 the maximum of the two values. +func Max32(a, b float32) float32 { + return float32(math.Max(float64(a), float64(b))) +} + +// Min the minimum of the two values. +func Min(a, b float64) float64 { + return math.Min(a, b) +} + +// Min32 the minimum of the two values. +func Min32(a, b float32) float32 { + return float32(math.Min(float64(a), float64(b))) +} + +// NaN returns not a floating point number. +func NaN() float64 { + return math.NaN() +} + +// NaN32 returns not a floating point number. +func NaN32() float32 { + return float32(NaN()) +} + +// Pow returns the power e of base b. +func Pow(b, e float64) float64 { + return math.Pow(b, e) +} + +// Pow32 returns the power e of base b. +func Pow32(b, e float32) float32 { + return float32(Pow(float64(b), float64(e))) +} + +// Round rounds to the nearest integer. +func Round(f float64) float64 { + return math.Round(f) +} + +// Round32 rounds to the nearest integer. +func Round32(f float32) float32 { + return float32(math.Round(float64(f))) +} + +// Sin returns the sine of f. +func Sin(f float64) float64 { + return math.Sin(f) +} + +// Sin32 returns the sine of f. +func Sin32(f float32) float32 { + return float32(math.Sin(float64(f))) +} + +// Sq returns the squared value of f. +func Sq(f float64) float64 { + return f * f +} + +// Sq32 returns the squared value of f. +func Sq32(f float32) float32 { + return f * f +} + +// Sqrt the square root of the value. +func Sqrt(f float64) float64 { + return math.Sqrt(f) +} + +// Sqrt32 the square root of the value. +func Sqrt32(f float32) float32 { + return float32(Sqrt(float64(f))) +} + +// Tan returns the tangent of f. +func Tan(f float64) float64 { + return math.Tan(f) +} + +// Tan32 returns the tangent of f. +func Tan32(f float32) float32 { + return float32(math.Tan(float64(f))) +}