java.lang.Object
imagingbook.common.noise.hashing.Hash32
All Implemented Interfaces:
HashFunction
Direct Known Subclasses:
Hash32Shift, Hash32ShiftMult, Hash32Ward

public abstract class Hash32 extends Object implements HashFunction
Hash functions for gradient (Perlin) noise.
Version:
2022/11/24
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Hash32(int seed)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    hash(int u)
    1D hash function: maps a single int key to a double hash value in [0,1].
    double[]
    hash(int[] p)
    N-dimensional permutation hash; this version does not use any bit splitting.
    double[]
    hash(int u, int v)
    2D hash function: maps a pair of int keys to a pair of double hash values in [0,1].
    double[]
    hash(int u, int v, int w)
    3D hash function: maps a triplet of int keys to a triplet of double hash values in [0,1].

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Hash32

      protected Hash32(int seed)
  • Method Details

    • hash

      public double hash(int u)
      Description copied from interface: HashFunction
      1D hash function: maps a single int key to a double hash value in [0,1].
      Specified by:
      hash in interface HashFunction
      Parameters:
      u - the key
      Returns:
      the hash value
    • hash

      public double[] hash(int u, int v)
      Description copied from interface: HashFunction
      2D hash function: maps a pair of int keys to a pair of double hash values in [0,1].
      Specified by:
      hash in interface HashFunction
      Parameters:
      u - the 1st key
      v - the 2nd key
      Returns:
      the hash values
    • hash

      public double[] hash(int u, int v, int w)
      Description copied from interface: HashFunction
      3D hash function: maps a triplet of int keys to a triplet of double hash values in [0,1].
      Specified by:
      hash in interface HashFunction
      Parameters:
      u - the 1st key
      v - the 2nd key
      w - the 3rd key
      Returns:
      the hash values
    • hash

      public double[] hash(int[] p)
      N-dimensional permutation hash; this version does not use any bit splitting. Instead, the hashInt() function is applied repeatedly for every gradient dimension by using the dimension number (k) as a local seed - in addition to the global seed (seed).
      Specified by:
      hash in interface HashFunction
      Parameters:
      p - a N-vector of keys
      Returns:
      a N-vector of hash values