xmath

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: Zlib Imports: 4 Imported by: 0

README

xmath

Package xmath provides mathematics routines convenient to xirho and its components.

Currently, this provides the RNG implementation and some helpers for coordinate systems.

Documentation

Overview

Package xmath provides mathematics routines convenient to xirho and its components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Angle

func Angle(x float64) float64

Angle wraps a float64 value to the interval (-pi, pi]. The result may be NaN if the argument is not finite.

func FromSpherical

func FromSpherical(r, theta, phi float64) (x, y, z float64)

FromSpherical converts spherical (r, θ, φ) coordinates to rectangular (x, y, z).

func IsFinite

func IsFinite(x float64) bool

IsFinite returns whether the argument is finite.

func R3

func R3(x, y, z float64) float64

R3 calculates the Euclidean distance from the origin to the given point.

func Spherical

func Spherical(x, y, z float64) (r, theta, phi float64)

Spherical converts rectangular (x, y, z) coordinates to spherical (r, θ, φ).

Types

type RNG

type RNG struct {
	// contains filtered or unexported fields
}

RNG is the randomness source type for xirho, an implementation of xoshiro256** by David Blackman and Sebastiano Vigna.

func NewRNG

func NewRNG() RNG

NewRNG produces a new, uniquely seeded RNG.

func (*RNG) Intn

func (rng *RNG) Intn(n int) int

Intn produces an int in [0, n). Panics if n <= 0.

func (*RNG) Jump

func (rng *RNG) Jump()

Jump quickly advances the generator by 2**192 steps.

func (*RNG) Normal

func (rng *RNG) Normal() float64

Normal generates a variate from the standard normal distribution.

func (*RNG) Uint64

func (rng *RNG) Uint64() uint64

Uint64 produces a 64-bit pseudo-random value.

func (*RNG) Uniform

func (rng *RNG) Uniform() float64

Uniform generates a number in the interval [0, 1).

Jump to

Keyboard shortcuts

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