Documentation ¶
Overview ¶
Package util provides miscellaneous maths functions.
Index ¶
- func Assert(test bool)
- func Check(err error)
- func CheckNaN(v float64)
- func CheckNaNVec(v [3]float64)
- func Cos(x float64) float64
- func Dither(rng *rand.Rand, x float64) int
- func Frac(x float64) float64
- func IsBad(v float64) bool
- func IsBadVec(v [3]float64) bool
- func Max(x, y float64) float64
- func Max3(x, y, z float64) float64
- func Min(x, y float64) float64
- func Re(x float64) float64
- func Sin(x float64) float64
- func Sinc(x float64) float64
- func Sqr(x float64) float64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNaNVec ¶
func CheckNaNVec(v [3]float64)
func Cos ¶
Cos is like math.Cos, but returns exactly 0 for arguments Pi/2, -Pi/2. this avoids annoying round-off errors for rotations of multiples of 90 degrees.
func Frac ¶
Frac returns x % 1, using python-like modulus.
Example ¶
for _, x := range []float64{-2.1, -2, -1.9, -1, -0.1, 0, 0.1, 0.9, 1, 1.1, 2, 2.1} { fmt.Printf("Frac(% .1f) = % .1f\n", x, Frac(x)) }
Output: Frac(-2.1) = 0.9 Frac(-2.0) = 0.0 Frac(-1.9) = 0.1 Frac(-1.0) = 0.0 Frac(-0.1) = 0.9 Frac( 0.0) = 0.0 Frac( 0.1) = 0.1 Frac( 0.9) = 0.9 Frac( 1.0) = 0.0 Frac( 1.1) = 0.1 Frac( 2.0) = 0.0 Frac( 2.1) = 0.1
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.