Class Utils

java.lang.Object
org.spongepowered.noise.Utils

public final class Utils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    clamp(int value, int low, int high)
    Clamps the value between the low and high boundaries
    static double
    cubicInterp(double n0, double n1, double n2, double n3, double a)
    Performs cubic interpolation between two values bound between two other values
    static int
    floor(double x)
    Rounds x down to the closest integer
    static double[]
    latLonToXYZ(double latitude, double longitude)
     
    static double
    linearInterp(double n0, double n1, double a)
    Performs linear interpolation between two values
    static 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-Curve
    static double
    sCurve5(double a)
    maps a value onto a quitnic S-Curve
    static void
    setupLegacyMode(boolean enableLegacyRange)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 value
      n1 - the first value
      n2 - the second value
      n3 - the value after the second value
      a - 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 value
      n1 - second value
      a - 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, and z 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 clamp
      low - The low bound of the clamp
      high - 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)