java.lang.Object
org.spongepowered.noise.Utils
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
clamp
(int value, int low, int high) Clamps the value between the low and high boundariesstatic double
cubicInterp
(double n0, double n1, double n2, double n3, double a) Performs cubic interpolation between two values bound between two other valuesstatic int
floor
(double x) Rounds x down to the closest integerstatic double[]
latLonToXYZ
(double latitude, double longitude) static double
linearInterp
(double n0, double n1, double a) Performs linear interpolation between two valuesstatic double
makeInt32Range
(double n) Modifies a floating-point value so that it can be stored in a noise::int32 variable.static double
sCurve3
(double a) Maps a value onto a cubic S-Curvestatic double
sCurve5
(double a) maps a value onto a quitnic S-Curvestatic void
setupLegacyMode
(boolean enableLegacyRange)
-
Method Details
-
cubicInterp
public static double cubicInterp(double n0, double n1, double n2, double n3, double a) Performs cubic interpolation between two values bound between two other values- Parameters:
n0
- the value before the first valuen1
- the first valuen2
- the second valuen3
- the value after the second valuea
- the alpha value- Returns:
- the interpolated value
-
linearInterp
public static double linearInterp(double n0, double n1, double a) Performs linear interpolation between two values- Parameters:
n0
- first valuen1
- second valuea
- the alpha value. Should be between 0 and 1.- Returns:
- the interpolated value
-
sCurve3
public static double sCurve3(double a) Maps a value onto a cubic S-Curve- Parameters:
a
- the value to map onto a S-Curve- Returns:
- the mapped value
-
sCurve5
public static double sCurve5(double a) maps a value onto a quitnic S-Curve- Parameters:
a
- the value to map onto a quitic S-curve- Returns:
- the mapped value
-
latLonToXYZ
public static double[] latLonToXYZ(double latitude, double longitude) -
makeInt32Range
public static double makeInt32Range(double n) Modifies a floating-point value so that it can be stored in a noise::int32 variable.This function does not modify
n
.In libnoise, the noise-generating algorithms are all integer-based; they use variables of type noise::int32. Before calling a noise function, pass the
x
,y
, andz
coordinates to this function to ensure that these coordinates can be cast to a noise::int32 value.Although you could do a straight cast from double to noise::int32, the resulting value may differ between platforms. By using this function, you ensure that the resulting value is identical between platforms.
- Parameters:
n
- A floating-point number.- Returns:
- The modified floating-point number.
-
clamp
public static int clamp(int value, int low, int high) Clamps the value between the low and high boundaries- Parameters:
value
- The value to clamplow
- The low bound of the clamphigh
- The high bound of the clamp- Returns:
- the clamped value
-
floor
public static int floor(double x) Rounds x down to the closest integer- Parameters:
x
- The value to floor- Returns:
- The closest integer
-
setupLegacyMode
public static void setupLegacyMode(boolean enableLegacyRange)
-