Package squidpony.squidmath
Class SeededNoise
java.lang.Object
squidpony.squidmath.SeededNoise
- All Implemented Interfaces:
Noise.Noise2D,Noise.Noise3D,Noise.Noise4D,Noise.Noise6D
- Direct Known Subclasses:
WhirlingNoise
public class SeededNoise extends Object implements Noise.Noise2D, Noise.Noise3D, Noise.Noise4D, Noise.Noise6D
More advanced noise functions, in 2D, 3D, 4D, and 6D, with the last two as options for generating seamlessly-tiling
noise using
Noise.seamless2D(double[][], long, int, Noise.Noise4D) and/or
Noise.seamless3D(double[][][], long, int, Noise.Noise6D). All functions can take a long seed that should
significantly change the pattern of noise produced. Incorporates code from Joise; the full library is available at
https://github.com/SudoPlayGames/Joise , and this class adds rather significant optimization in a few methods,
especially 6D noise. Joise is derived from the Accidental Noise Library, available in C++ at
http://accidentalnoise.sourceforge.net/index.html . Both Joise and ANL have many features that SquidLib has not (yet)
incorporated, but now that SquidLib has seamless noise, that's a nice feature that would have needed Joise before.-
Field Summary
Fields Modifier and Type Field Description protected longdefaultSeedprotected static doubleF2protected static doubleF3protected static doubleF4protected static doubleF6protected static doubleG2protected static doubleG3protected static doubleG4protected static doubleG6protected static float[]grad3dprotected static double[]grad4dprotected static double[]gradient6DLUTstatic SeededNoiseinstanceprotected static doubleLIMIT4protected static doubleLIMIT6static double[][]phiGrad2256 2-element gradient vectors formed from the cos and sin of increasing multiples of the inverse of phi, the golden ratio, while also adding increasing multiples of 2/3 of the reciprocal ofMath.E.protected static int[]SIMPLEX_4DUsed bynoise(double, double, double, double, long)to look up the vertices of the 4D triangle analogue. -
Constructor Summary
Constructors Constructor Description SeededNoise()SeededNoise(long seed) -
Method Summary
Modifier and Type Method Description doublegetNoise(double x, double y)doublegetNoise(double x, double y, double z)doublegetNoise(double x, double y, double z, double w)doublegetNoise(double x, double y, double z, double w, double u, double v)doublegetNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)doublegetNoiseWithSeed(double x, double y, double z, double w, long seed)doublegetNoiseWithSeed(double x, double y, double z, long seed)doublegetNoiseWithSeed(double x, double y, long seed)protected static doublegradCoord3D(long seed, int x, int y, int z, double xd, double yd, double zd)Computes the hash for a 3D int point and its dot product with a 3D double point as one step.static doublenoise(double x, double y, double z, double w, double u, double v, long seed)static doublenoise(double x, double y, double z, double w, long seed)static doublenoise(double x, double y, double z, long seed)static doublenoise(double x, double y, long seed)
-
Field Details
-
phiGrad2
256 2-element gradient vectors formed from the cos and sin of increasing multiples of the inverse of phi, the golden ratio, while also adding increasing multiples of 2/3 of the reciprocal ofMath.E. This produces a sequence with remarkably low overlap possible from nearby angles, distributed nicely around the unit circle. For i from 1 to 256 inclusive, this gets the cosine and sine of an angle in radians of0.61803398874989484820458683436563811772 * i + (i / (1.5 * 2.7182818284590452354)). This is expected to be accessed using an 8-bit int (depending on how you got your int, the normal way to get 8 bits would beindex & 255), but smaller numbers should also work down to about 4 bits (typically usingindex & 15). -
grad3d
-
grad4d
-
defaultSeed
-
instance
-
gradient6DLUT
-
SIMPLEX_4D
Used bynoise(double, double, double, double, long)to look up the vertices of the 4D triangle analogue. -
F2
- See Also:
- Constant Field Values
-
G2
- See Also:
- Constant Field Values
-
F3
- See Also:
- Constant Field Values
-
G3
- See Also:
- Constant Field Values
-
F4
-
G4
-
LIMIT4
- See Also:
- Constant Field Values
-
F6
-
G6
-
LIMIT6
- See Also:
- Constant Field Values
-
-
Constructor Details
-
SeededNoise
public SeededNoise() -
SeededNoise
-
-
Method Details
-
gradCoord3D
protected static double gradCoord3D(long seed, int x, int y, int z, double xd, double yd, double zd)Computes the hash for a 3D int point and its dot product with a 3D double point as one step.- Parameters:
seed-x-y-z-xd-yd-zd-- Returns:
- a double between -1.2571 and 1.2571, exclusive
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise2D
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise3D
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise4D
-
getNoise
- Specified by:
getNoisein interfaceNoise.Noise6D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeedin interfaceNoise.Noise2D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeedin interfaceNoise.Noise3D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeedin interfaceNoise.Noise4D
-
getNoiseWithSeed
public double getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)- Specified by:
getNoiseWithSeedin interfaceNoise.Noise6D
-
noise
-
noise
-
noise
-
noise
-