Package com.jhlabs.math
Class Noise
- java.lang.Object
-
- com.jhlabs.math.Noise
-
- All Implemented Interfaces:
Function1D
,Function2D
,Function3D
public class Noise extends java.lang.Object implements Function1D, Function2D, Function3D
Perlin Noise functions
-
-
Constructor Summary
Constructors Constructor Description Noise()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description float
evaluate(float x)
Compute 1-dimensional Perlin noise.float
evaluate(float x, float y)
Compute 2-dimensional Perlin noise.float
evaluate(float x, float y, float z)
Compute 3-dimensional Perlin noise.static float[]
findRange(Function1D f, float[] minmax)
Returns the minimum and maximum of a number of random values of the given function.static float[]
findRange(Function2D f, float[] minmax)
Returns the minimum and maximum of a number of random values of the given function.static float
lerp(float t, float a, float b)
static float
noise1(float x)
Compute 1-dimensional Perlin noise.static float
noise2(float x, float y)
Compute 2-dimensional Perlin noise.static float
noise3(float x, float y, float z)
Compute 3-dimensional Perlin noise.static float
turbulence2(float x, float y, float octaves)
Compute turbulence using Perlin noise.static float
turbulence3(float x, float y, float z, float octaves)
Compute turbulence using Perlin noise.
-
-
-
Method Detail
-
evaluate
public float evaluate(float x)
Compute 1-dimensional Perlin noise.- Specified by:
evaluate
in interfaceFunction1D
- Parameters:
x
- the x value- Returns:
- noise value at x in the range -1..1
-
evaluate
public float evaluate(float x, float y)
Compute 2-dimensional Perlin noise.- Specified by:
evaluate
in interfaceFunction2D
- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
- noise value at (x,y)
-
evaluate
public float evaluate(float x, float y, float z)
Compute 3-dimensional Perlin noise.- Specified by:
evaluate
in interfaceFunction3D
- Parameters:
x
- the x coordinatey
- the y coordinatey
- the y coordinate- Returns:
- noise value at (x,y,z)
-
turbulence2
public static float turbulence2(float x, float y, float octaves)
Compute turbulence using Perlin noise.- Parameters:
x
- the x valuey
- the y valueoctaves
- number of octaves of turbulence- Returns:
- turbulence value at (x,y)
-
turbulence3
public static float turbulence3(float x, float y, float z, float octaves)
Compute turbulence using Perlin noise.- Parameters:
x
- the x valuey
- the y valuez
- the z valueoctaves
- number of octaves of turbulence- Returns:
- turbulence value at (x,y,z)
-
noise1
public static float noise1(float x)
Compute 1-dimensional Perlin noise.- Parameters:
x
- the x value- Returns:
- noise value at x in the range -1..1
-
noise2
public static float noise2(float x, float y)
Compute 2-dimensional Perlin noise.- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
- noise value at (x,y)
-
noise3
public static float noise3(float x, float y, float z)
Compute 3-dimensional Perlin noise.- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate- Returns:
- noise value at (x,y,z)
-
lerp
public static float lerp(float t, float a, float b)
-
findRange
public static float[] findRange(Function1D f, float[] minmax)
Returns the minimum and maximum of a number of random values of the given function. This is useful for making some stab at normalising the function.- Parameters:
f
- The 1D functionminmax
- An array of two floats- Returns:
- The minimum and maximum
-
findRange
public static float[] findRange(Function2D f, float[] minmax)
Returns the minimum and maximum of a number of random values of the given function. This is useful for making some stab at normalising the function.- Parameters:
f
- The two dimensional functionminmax
- An array of two floats- Returns:
- The minimum and maximum
-
-