Documentation ¶
Overview ¶
Package rand provides random number functions that are missing in the standard library, as well as other forms of random numbers such as proceedural noise (eg Perlin noise)
Index ¶
- func CellNoiseSlow(lambda, max int, dist data.DistanceMetric) func(x, y float64) float64
- func FillPermutation(seed int64)
- func Float64NM(low, high float64) float64
- func IntNM(low, high int) int
- func MakeNoisePoints2D(xrange, yrange [2]int, maxPtsPerCell int, cdf []float64, p *[512]int) []data.Interface
- func MakeNoisePoints3D(xrange, yrange, zrange [2]int, maxPtsPerCell int, cdf []float64, p *[512]int) []data.Interface
- func MakePermutation(seed int64) (perm *[512]int)
- func Noise1(x float64) float64
- func Noise2(x, y float64) float64
- func Noise3(x, y, z float64) float64
- func Noise3Octaves(x, y, z float64, octaves int, lacunarity, persistence float64) float64
- type CellNoise2D
- type CellNoise3D
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CellNoiseSlow ¶
func CellNoiseSlow(lambda, max int, dist data.DistanceMetric) func(x, y float64) float64
CellNoiseSlow creates a function which gives 2D cell noise. Lambda and max determine the number of feature points in a given unit cube, which lambda is the average number per cell and max is the maximum number per cell. DistanceMetric dist provides the notion of 'distance'.
func FillPermutation ¶
func FillPermutation(seed int64)
FillPermutation changes the permutation table used for noise generation. If a source is provided, it uses that. Otherwise, it uses a source seeded with the time.Now().UnixNano().
func Float64NM ¶
Float64NM produced a random float64 in the range [low,high) from the standard source. Assumes source is already seeded. Panics if low >= high.
func IntNM ¶
IntNM produced a random int in the range [low,high) from the standard source. Assumes source is already seeded. Panics if low >= high.
func MakeNoisePoints2D ¶
func MakeNoisePoints2D(xrange, yrange [2]int, maxPtsPerCell int, cdf []float64, p *[512]int) []data.Interface
MakeNoisePoints2D generates all the points for all the cells given the parameters.
func MakeNoisePoints3D ¶
func MakeNoisePoints3D(xrange, yrange, zrange [2]int, maxPtsPerCell int, cdf []float64, p *[512]int) []data.Interface
MakeNoisePoints3D generates all the points for all the cells given the parameters.
func MakePermutation ¶
MakePermutation makes a permutation table used in noise generation.
func Noise3 ¶
Noise3 returns 3d perlin noise based on Ken Perlin's 2002 "improved noise" algorithm.
See: http://mrl.nyu.edu/~perlin/noise/ Paper: http://mrl.nyu.edu/~perlin/paper445.pdf
func Noise3Octaves ¶
Noise3Octaves uses the idea of adding diffent samplings of perlin noise together to add a "fractal" quality to the detail of the noise produced.
octaves is the number of samples taken and added together, usually 3 or 4 is a good. lacunarity is the rate at which the frequency (space between samplings) increases, usually 2. persistence is the rate at which the amplitude (how much sample affects octave) decreases, usually 0.5.
See: http://flafla2.github.io/2014/08/09/perlinnoise.html and: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm (may be broken)
Types ¶
type CellNoise2D ¶
type CellNoise2D struct {
// contains filtered or unexported fields
}
CellNoise2D contains the configuration data for a 2D cell noise generator.
func NewCellNoise2D ¶
func NewCellNoise2D(seed int64, lambda, maxPtsPerCell int, dist data.DistanceMetric) *CellNoise2D
NewCellNoise2D creates a pointer to a new CellNoise2D struct.
Lambda and max determine the number of feature points in a given unit cube, where lambda is the average number per cell and maxPtsPerCell is the maximum number per cell. DistanceMetric dist provides the notion of 'distance'.
func (*CellNoise2D) Noise ¶
func (conf *CellNoise2D) Noise(x, y float64) float64
Noise gets a noise value at the given point (x, y).
type CellNoise3D ¶
type CellNoise3D struct {
// contains filtered or unexported fields
}
CellNoise3D contains the configuration data for a 3D cell noise generator.
func NewCellNoise3D ¶
func NewCellNoise3D(seed int64, lambda, maxPtsPerCell int, dist data.DistanceMetric) *CellNoise3D
NewCellNoise3D creates a pointer to a new CellNoise3D struct.
Lambda and max determine the number of feature points in a given unit cube, where lambda is the average number per cell and maxPtsPerCell is the maximum number per cell. DistanceMetric dist provides the notion of 'distance'.
func (*CellNoise3D) Noise ¶
func (conf *CellNoise3D) Noise(x, y, z float64) float64
Noise generates a noise value at the (x,y,z) location.
Directories ¶
Path | Synopsis |
---|---|
Package main is a simple demo of cell noise.
|
Package main is a simple demo of cell noise. |
Package main is a simple visualization of perlin noise.
|
Package main is a simple visualization of perlin noise. |