public class IntPointHash extends IPointHash.IntImpl
HastyPointHash
but will be much faster on GWT. This
implementation has high enough quality to be useful as a source of random numbers based on positions, but would
likely not be a good option in a hash table (or at least not as good as the tailored implementation of
Coord.hashCode()
; it is still better than Objects.hash(Object...)
). Even on a desktop
JVM, this class is faster than PointHash
or HastyPointHash
. The technique used here
owes credit to Pelle Evensen for finding the significant quality increase from using multiple bitwise rotations XORed
together, and Martin Roberts for discovering the connection between higher dimensional ranks and the appropriate
numbers to gain similar qualities to adding the golden ratio mod 1 in 1D, using what had already been named
"harmonious numbers." The only case where this can return different results on GWT than on a desktop or mobile
JVM is when the inputs are GWT-specific out-of-range JS Numbers appearing to be ints, and that's a problem with
the input rather than the algorithm.
hashAll(int, int, int)
, dividing to get a float from 0 to 1, and graphing
it produces this white-noise-like image. The frequency magnitude of
that image is this diagram, which looks almost exactly like
a diagram of the frequency magnitude of white noise. This shows
there are effectively no significant structural artifacts in the noise when interpreted as a float.IPointHash.IntImpl, IPointHash.LongImpl
Modifier and Type | Field and Description |
---|---|
static IntPointHash |
INSTANCE |
state
Constructor and Description |
---|
IntPointHash() |
IntPointHash(int state) |
Modifier and Type | Method and Description |
---|---|
static int |
hash256(int x,
int y,
int s)
A 8-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash256(int x,
int y,
int z,
int s)
A 8-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash256(int x,
int y,
int z,
int w,
int s)
A 8-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash256(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 8-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int s)
A 5-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int z,
int s)
A 5-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int z,
int w,
int s)
A 5-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 5-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int s)
A 6-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int z,
int s)
A 6-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int z,
int w,
int s)
A 6-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 6-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hashAll(int x,
int y,
int s)
A 32-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hashAll(int x,
int y,
int z,
int s)
A 32-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hashAll(int x,
int y,
int z,
int w,
int s)
A 32-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hashAll(int x,
int y,
int z,
int w,
int u,
int s)
A 32-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hashAll(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 32-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
int |
hashWithState(int x,
int y,
int state) |
int |
hashWithState(int x,
int y,
int z,
int state) |
int |
hashWithState(int x,
int y,
int z,
int w,
int state) |
int |
hashWithState(int x,
int y,
int z,
int w,
int u,
int state) |
int |
hashWithState(int x,
int y,
int z,
int w,
int u,
int v,
int state) |
public static final IntPointHash INSTANCE
public int hashWithState(int x, int y, int state)
public int hashWithState(int x, int y, int z, int state)
public int hashWithState(int x, int y, int z, int w, int state)
public int hashWithState(int x, int y, int z, int w, int u, int state)
public int hashWithState(int x, int y, int z, int w, int u, int v, int state)
public static int hashAll(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int w, int u, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointCopyright © Eben Howard 2012–2022. All rights reserved.