Hashing functions.
More...
#include <noise.h>
|
| static int | Integer (int, int, int) |
| | Fast integer hashing.
|
| static unsigned int | Morton (unsigned int, unsigned int) |
| | Morton codes in the plane.
|
| static unsigned int | Morton (unsigned int, unsigned int, unsigned int) |
| | Morton codes in 3D space.
|
| static int | Double (const double &, const double &, const double &) |
| | Fast hashing for points.
|
| static int | Double (const double &, const double &) |
| | Fast hashing for points in the plane.
|
| static int | Double (const Vector &) |
| | Fast and convenient hashing for vectors.
|
| static int | Double (const Vector2 &) |
| | Fast and convenient hashing for vectors in the plane.
|
Hashing functions.
A good reference to a variety of hashing functions: http://burtleburtle.net/bob/hash/integer.html
This class implements several simple and efficient hashing functions, which are used in the definition or some noise classes such as GaborNoise.
◆ Double() [1/4]
| int Hashing::Double |
( |
const double & | x, |
|
|
const double & | y ) |
|
inlinestatic |
Fast hashing for points in the plane.
- Parameters
-
◆ Double() [2/4]
| int Hashing::Double |
( |
const double & | x, |
|
|
const double & | y, |
|
|
const double & | z ) |
|
inlinestatic |
Fast hashing for points.
- Parameters
-
◆ Double() [3/4]
| int Hashing::Double |
( |
const Vector & | p | ) |
|
|
static |
◆ Double() [4/4]
| int Hashing::Double |
( |
const Vector2 & | p | ) |
|
|
static |
◆ Integer()
| int Hashing::Integer |
( |
int | x, |
|
|
int | y, |
|
|
int | z ) |
|
inlinestatic |
Fast integer hashing.
- Parameters
-
| x,y,z | Integer coordinates. |
◆ Morton() [1/2]
| unsigned int Hashing::Morton |
( |
unsigned int | x, |
|
|
unsigned int | y ) |
|
static |
Morton codes in the plane.
Interleaves the bits of x and y using the parallel-prefix "magic bits" technique, which runs in O(1) (5 masks + 5 shifts per coordinate) instead of a 32-iteration loop. Only the lower 16 bits of each coordinate are used, as they fully occupy the 32-bit result.
The original loop-based implementation was:
unsigned int m = 0;
for (unsigned int i = 0; i < 32; i++)
m |= ((x & (1u << i)) << i) | ((y & (1u << i)) << (i + 1));
return m;
- Parameters
-
| x,y | Integer positive coordinates (lower 16 bits used) |
◆ Morton() [2/2]
| unsigned int Hashing::Morton |
( |
unsigned int | x, |
|
|
unsigned int | y, |
|
|
unsigned int | z ) |
|
static |
Morton codes in 3D space.
Interleaves the lower 10 bits of each coordinate into a 30-bit result. Only coordinates in [0, 1023] are fully represented; higher bits are silently ignored.
- Parameters
-
| x,y,z | Integer positive coordinates (lower 10 bits used). |