Core 1.0
Hash2 Class Reference

PCG2D hashing of two integer coordinates. More...

#include <hashing.h>

Static Public Member Functions

static int Integer (int, int)
 Hash of integer coordinates.
static double Value (int, int)
 Hash of integer coordinates, as a real number.
static void Integer2 (int, int, int &, int &)
 Hash of integer coordinates, as two integers.
static Vector2 Value2 (int, int)
 Hash of integer coordinates, as a vector in the plane.
static QString Glsl ()
 GLSL source code equivalent to the functions of Hash2.

Static Protected Member Functions

static void Pcg (uint32_t &, uint32_t &)
 Core of the pcg2d hash.

Detailed Description

PCG2D hashing of two integer coordinates.

Same as Hash, in the plane, using the pcg2d hash.

See also
Hash

Member Function Documentation

◆ Glsl()

QString Hash2::Glsl ( )
static

GLSL source code equivalent to the functions of Hash2.

Defines the functions uvec2 Hash2u(uvec2), vec2 Hash2f(uvec2) (equivalent to Hash2::Integer2() and Hash2::Value2()), int HashInteger(int,int) and float HashValue(int,int) (equivalent to Hash2::Integer() and Hash2::Value()).

◆ Integer()

int Hash2::Integer ( int x,
int y )
inlinestatic

Hash of integer coordinates.

Parameters
x,yInteger coordinates.
Returns
A pseudo-random integer, covering the whole range of int.

◆ Integer2()

void Hash2::Integer2 ( int x,
int y,
int & a,
int & b )
inlinestatic

Hash of integer coordinates, as two integers.

Unlike Hash2::Integer(), which only keeps the first component, the two components of the pcg2d output are returned.

Parameters
x,yInteger coordinates.
a,bPseudo-random integers, covering the whole range of int.

◆ Pcg()

void Hash2::Pcg ( uint32_t & x,
uint32_t & y )
inlinestaticprotected

Core of the pcg2d hash.

Parameters
x,yValues, modified in place.

◆ Value()

double Hash2::Value ( int x,
int y )
inlinestatic

Hash of integer coordinates, as a real number.

Parameters
x,yInteger coordinates.
Returns
A pseudo-random number in [0,1).
See also
Hash::Value

◆ Value2()

Vector2 Hash2::Value2 ( int x,
int y )
inlinestatic

Hash of integer coordinates, as a vector in the plane.

Each coordinate of the vector is computed as in Hash2::Value() from the corresponding component of the pcg2d output.

Parameters
x,yInteger coordinates.
Returns
A pseudo-random vector in [0,1)^2.