Amortized Noise Terrain Generator
A Program to Generate Terrain from Amortized Noise with Exponentially Distributed Gradient Magnitude
Macros | Functions
ExponentialHash.cpp File Reference

Code for generating an exponentially distributed hash function. More...

#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include "defines.h"

Macros

#define clip(x, a, b)   min(max(x, a), b)
 Clip x to [a,b].
 

Functions

float UniformHash (unsigned int x, unsigned int max)
 Uniform hash. More...
 
float ExpHash (unsigned int x, unsigned int max)
 Exponential hash. More...
 
float ExpHash (unsigned int x, unsigned int y, unsigned int m, float omega)
 Exponential hash with control of exponent and tail of distribution. More...
 

Function Documentation

◆ ExpHash() [1/2]

float ExpHash ( unsigned int  x,
unsigned int  max 
)

Exponentially distributed hash function.

Hash an unsigned integer into the range (0, 1) with an exponential distribution.

Parameters
xValue to be hashed.
maxLargest possible value of x.
Returns
An exponentially distributed hash value > 0 and < 1.

◆ ExpHash() [2/2]

float ExpHash ( unsigned int  x,
unsigned int  y,
unsigned int  m,
float  omega 
)

Exponentially distributed hash function.

Hash an unsigned integer into the range (0, 1) with an exponential distribution giving some control over the base of the exponent and the height of the tail of the distribution.

Parameters
xValue to be hashed.
ySecond value to be hashed to select distribution.
mLargest possible value of x.
omegaThe tail multiplier, which controls how low the tails of the distribution can be.
Returns
An exponentially distributed random number > 0 and < 1.

◆ UniformHash()

float UniformHash ( unsigned int  x,
unsigned int  max 
)

Uniformly distributed hash function.

Hash an unsigned integer uniformly into the range (0, 1).

Parameters
xValue to be hashed.
maxLargest possible value of x.
Returns
A uniformly distributed hash value > 0 and < 1.