util

package
v0.0.0-...-405cb25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package util provides miscellaneous maths functions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(test bool)

func Check

func Check(err error)

func CheckNaN

func CheckNaN(v float64)

func CheckNaNVec

func CheckNaNVec(v [3]float64)

func Cos

func Cos(x float64) float64

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 Dither

func Dither(rng *rand.Rand, x float64) int

func Frac

func Frac(x float64) float64

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

func IsBad

func IsBad(v float64) bool

func IsBadVec

func IsBadVec(v [3]float64) bool

func Max

func Max(x, y float64) float64

func Max3

func Max3(x, y, z float64) float64

func Min

func Min(x, y float64) float64

func Re

func Re(x float64) float64

func Sin

func Sin(x float64) float64

Sin is like math.Sin, but returns exactly 0 for arguments Pi, -Pi. this avoids annoying round-off errors for rotations of multiples of 90 degrees.

func Sinc

func Sinc(x float64) float64

Sinc returns sin(x)/x, handling x == 0 gracefully.

func Sqr

func Sqr(x float64) float64

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL