Class LineWobble

java.lang.Object
com.github.tommyettinger.random.LineWobble

public class LineWobble extends Object
Provides 1D noise methods that can be queried at any point on a line to get a continuous random value. These each use some form of low-quality, high-speed unary hash on the floor and ceiling of a float or double value, then interpolate between the hash results. Some of these work on angles (so they wrap like a line around a circle) instead of normal lines.
Some methods here were named... hastily, but the names stuck.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    bicubicWobble(int seed, double t)
    Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after).
    static float
    bicubicWobble(int seed, float t)
    Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after).
    static double
    bicubicWobble(long seed, double t)
    Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after).
    static float
    bicubicWobble(long seed, float t)
    Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after).
    static float[]
    generateLookupTable(int seed, int size, int points, int octaves)
    Creates a wrapping lookup table of size float items for a wobbling line, using a specific count of points where the wobble can reach a peak or valley, a number of octaves to refine the wobble, and a seed.
    static float[]
    generateSplineLookupTable(int seed, int size, int points, int octaves, float shape, float turning)
    Creates a wrapping lookup table of size float items for a wobbling line, using a specific count of points where the wobble can reach a peak or valley, a number of octaves to refine the wobble, and a seed.
    static double
    hobble(long startBits, long endBits, double value)
    A variant on splobble(long, double) that takes some kind of hash-generated longs for the startBits and endBits.
    static float
    hobble(long startBits, long endBits, float value)
    A variant on splobble(long, float) that takes some kind of hash-generated longs for the startBits and endBits.
    static double
    quobble(int seed, double value)
    Quilez' 1D noise, with some changes to work on the CPU.
    static float
    quobble(int seed, float value)
    Quilez' 1D noise, with some changes to work on the CPU.
    static double
    quobble(long seed, double value)
    Quilez' 1D noise, with some changes to work on the CPU.
    static float
    quobble(long seed, float value)
    Quilez' 1D noise, with some changes to work on the CPU.
    static double
    quobbleOctave2(int seed, double x)
    Just gets two octaves of quobble(int, double); still has a range of -1 to 1.
    static float
    quobbleOctave2(int seed, float x)
    Just gets two octaves of quobble(int, float); still has a range of -1 to 1.
    static double
    quobbleOctave2(long seed, double x)
    Just gets two octaves of quobble(long, double); still has a range of -1 to 1.
    static float
    quobbleOctave2(long seed, float x)
    Just gets two octaves of quobble(long, float); still has a range of -1 to 1.
    static double
    smoothWobble(int seed, double t)
    Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values.
    static float
    smoothWobble(int seed, float t)
    Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values.
    static double
    smoothWobble(long seed, double t)
    Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values.
    static float
    smoothWobble(long seed, float t)
    Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values.
    static double
    splobble(int seed, double value)
    A variant on wobble(int, double) that uses MathTools.barronSpline(double, double, double) to interpolate between peaks/valleys, with the shape and turning point determined like the other values.
    static float
    splobble(int seed, float value)
    A variant on wobble(int, float) that uses MathTools.barronSpline(float, float, float) to interpolate between peaks/valleys, with the shape and turning point determined like the other values.
    static double
    splobble(long seed, double value)
    A variant on wobble(long, double) that uses MathTools.barronSpline(double, double, double) to interpolate between peaks/valleys, with the shape and turning point determined like the other values.
    static float
    splobble(long seed, float value)
    A variant on wobble(long, float) that uses MathTools.barronSpline(float, float, float) to interpolate between peaks/valleys, with the shape and turning point determined like the other values.
    static float
    splobbleAngle(int seed, float value)
    Like splobble(int, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in radians.
    static float
    splobbleAngle(long seed, float value)
    Like splobble(long, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in radians.
    static float
    splobbleAngleDeg(int seed, float value)
    Like splobble(int, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in degrees.
    static float
    splobbleAngleDeg(long seed, float value)
    Like splobble(long, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in degrees.
    static float
    splobbleAngleTurns(int seed, float value)
    Like splobble(int, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in turns.
    static float
    splobbleAngleTurns(long seed, float value)
    Like splobble(long, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in turns.
    static double
    trobble(int seed, double value)
    Trigonometric wobble.
    static float
    trobble(int seed, float value)
    Trigonometric wobble.
    static double
    trobble(long seed, double value)
    Trigonometric wobble.
    static float
    trobble(long seed, float value)
    Trigonometric wobble.
    static double
    wobble(int seed, double value)
    A variant on wobble(long, double) that takes an int seed instead of a long, and is optimized for usage on GWT.
    static float
    wobble(int seed, float value)
    A variant on wobble(long, float) that takes an int seed instead of a long, and is optimized for usage on GWT.
    static double
    wobble(long seed, double value)
    A mix of the smooth transitions of a sine wave with (seeded) random peaks and valleys between -1.0 and 1.0 (both exclusive).
    static float
    wobble(long seed, float value)
    A mix of the smooth transitions of a sine wave with (seeded) random peaks and valleys between -1f and 1f (both exclusive).
    static float
    wobbleAngle(int seed, float value)
    A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at pi * 2 so this can be used to get smoothly-changing random angles.
    static float
    wobbleAngle(long seed, float value)
    A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at pi * 2 so this can be used to get smoothly-changing random angles.
    static float
    wobbleAngleDeg(int seed, float value)
    A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 360.0 so this can be used to get smoothly-changing random angles.
    static float
    wobbleAngleDeg(long seed, float value)
    A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 360.0 so this can be used to get smoothly-changing random angles.
    static float
    wobbleAngleTurns(int seed, float value)
    A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 1.0 so this can be used to get smoothly-changing random angles in turns.
    static float
    wobbleAngleTurns(long seed, float value)
    A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 1.0 so this can be used to get smoothly-changing random angles in turns.
    static float
    wobbleWrapped(int seed, float value, int modulus)
    Very similar to wobble(int, float), but only tolerates non-negative value and wraps value when it gets too close to modulus.
    static float
    wobbleWrapped(long seed, float value, int modulus)
    Very similar to wobble(long, float), but only tolerates non-negative value and wraps value when it gets too close to modulus.
    static float
    wobbleWrappedTight(int seed, float value, int modulus)
    Very similar to wobble(int, float), but only tolerates non-negative value and wraps value when it gets too close to modulus.
    static float
    wobbleWrappedTight(long seed, float value, int modulus)
    Very similar to wobble(long, float), but only tolerates non-negative value and wraps value when it gets too close to modulus.

    Methods inherited from class java.lang.Object

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

    • LineWobble

      public LineWobble()
  • Method Details

    • wobble

      public static double wobble(long seed, double value)
      A mix of the smooth transitions of a sine wave with (seeded) random peaks and valleys between -1.0 and 1.0 (both exclusive). The pattern this will produce will be completely different if the seed changes, and it is suitable for 1D noise. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a double that typically changes slowly, by less than 1.0, with direction changes at integer inputs
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • wobble

      public static float wobble(long seed, float value)
      A mix of the smooth transitions of a sine wave with (seeded) random peaks and valleys between -1f and 1f (both exclusive). The pattern this will produce will be completely different if the seed changes, and it is suitable for 1D noise. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • wobble

      public static double wobble(int seed, double value)
      A variant on wobble(long, double) that takes an int seed instead of a long, and is optimized for usage on GWT. Like the version with a long seed, this uses cubic interpolation between random peak or valley points; only the method of generating those random peaks and valleys has changed.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a double that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • wobble

      public static float wobble(int seed, float value)
      A variant on wobble(long, float) that takes an int seed instead of a long, and is optimized for usage on GWT. Like the version with a long seed, this uses cubic interpolation between random peak or valley points; only the method of generating those random peaks and valleys has changed.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • bicubicWobble

      public static float bicubicWobble(int seed, float t)
      Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after). This pretty much never produces steep changes between peaks and valleys; this may make it more useful for things like generating terrain that can be walked across in a side-scrolling game.
      Parameters:
      seed - any int
      t - a distance traveled; should change by less than 1 between calls, and should be less than about 10000
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • bicubicWobble

      public static double bicubicWobble(int seed, double t)
      Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after). This pretty much never produces steep changes between peaks and valleys; this may make it more useful for things like generating terrain that can be walked across in a side-scrolling game.
      Parameters:
      seed - any int
      t - a distance traveled; should change by less than 1 between calls
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • bicubicWobble

      public static float bicubicWobble(long seed, float t)
      Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after). This pretty much never produces steep changes between peaks and valleys; this may make it more useful for things like generating terrain that can be walked across in a side-scrolling game.
      Parameters:
      seed - any long
      t - a distance traveled; should change by less than 1 between calls
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • bicubicWobble

      public static double bicubicWobble(long seed, double t)
      Sway smoothly using bicubic interpolation between 4 points (the two integers before t and the two after). This pretty much never produces steep changes between peaks and valleys; this may make it more useful for things like generating terrain that can be walked across in a side-scrolling game.
      Parameters:
      seed - any long
      t - a distance traveled; should change by less than 1 between calls
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • splobble

      public static float splobble(int seed, float value)
      A variant on wobble(int, float) that uses MathTools.barronSpline(float, float, float) to interpolate between peaks/valleys, with the shape and turning point determined like the other values. This can be useful when you want a curve to seem more "natural," without the similarity between every peak or every valley in wobble(int, float). This can produce both fairly sharp turns and very gradual curves.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • splobble

      public static double splobble(int seed, double value)
      A variant on wobble(int, double) that uses MathTools.barronSpline(double, double, double) to interpolate between peaks/valleys, with the shape and turning point determined like the other values. This can be useful when you want a curve to seem more "natural," without the similarity between every peak or every valley in wobble(int, double). This can produce both fairly sharp turns and very gradual curves.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a double that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • splobble

      public static float splobble(long seed, float value)
      A variant on wobble(long, float) that uses MathTools.barronSpline(float, float, float) to interpolate between peaks/valleys, with the shape and turning point determined like the other values. This can be useful when you want a curve to seem more "natural," without the similarity between every peak or every valley in wobble(long, float). This can produce both fairly sharp turns and very gradual curves.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • splobble

      public static double splobble(long seed, double value)
      A variant on wobble(long, double) that uses MathTools.barronSpline(double, double, double) to interpolate between peaks/valleys, with the shape and turning point determined like the other values. This can be useful when you want a curve to seem more "natural," without the similarity between every peak or every valley in wobble(long, double). This can produce both fairly sharp turns and very gradual curves.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a double that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • hobble

      public static float hobble(long startBits, long endBits, float value)
      A variant on splobble(long, float) that takes some kind of hash-generated longs for the startBits and endBits. This makes this usable as a building-block for noise with more than one dimension. Unlike the other wobbling-line methods here, value must be between 0 and 1 (inclusive). The name comes from "hash wobble." This can be useful when you want a curve to seem more "natural," without the similarity between every peak or every valley in wobble(long, float). This can produce both fairly sharp turns and very gradual curves.
      Parameters:
      startBits - any long; determines the result exactly when value is 0, and later affects it less
      endBits - any long; determines the result exactly when value is 1, and earlier affects it less
      value - a float between 0f and 1f, representing how much the result is affected by the start and end bits
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • hobble

      public static double hobble(long startBits, long endBits, double value)
      A variant on splobble(long, double) that takes some kind of hash-generated longs for the startBits and endBits. This makes this usable as a building-block for noise with more than one dimension. Unlike the other wobbling-line methods here, value must be between 0 and 1 (inclusive). The name comes from "hash wobble." This can be useful when you want a curve to seem more "natural," without the similarity between every peak or every valley in wobble(long, double). This can produce both fairly sharp turns and very gradual curves.
      Parameters:
      startBits - any long; determines the result exactly when value is 0, and later affects it less
      endBits - any long; determines the result exactly when value is 1, and earlier affects it less
      value - a double between 0.0 and 1.0, representing how much the result is affected by the start and end bits
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • quobble

      public static float quobble(int seed, float value)
      Quilez' 1D noise, with some changes to work on the CPU. Takes a distance value and any int seed, and produces a smoothly-changing result as value goes up or down and seed stays the same. Uses a quartic curve. The quartic curve means that at specific positions, each separated by an integer from each other, the noise will reliably be 0. This does not typically happen on integers for value, but it can if seed is 0 or some very high numbers.
      The distance (value) should be between -16384 and 1073733631 for this to return correct results. Because floats incur precision loss earlier than 1073733631, the actual upper bound is lower. The limit of -8192 comes from how this uses MathTools.fastFloor(float) internally on value + value.
      Parameters:
      value - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobbleOctave2

      public static float quobbleOctave2(int seed, float x)
      Just gets two octaves of quobble(int, float); still has a range of -1 to 1. This tends to look much more natural than just one octave of quobble(), because the points where it always will hit 0 are spaced differently for the two octaves here.
      Parameters:
      x - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobble

      public static double quobble(int seed, double value)
      Quilez' 1D noise, with some changes to work on the CPU. Takes a distance value and any int seed, and produces a smoothly-changing result as value goes up or down and seed stays the same. Uses a quartic curve. The quartic curve means that at specific positions, each separated by an integer from each other, the noise will reliably be 0. This does not typically happen on integers for value, but it can if seed is 0.
      Parameters:
      value - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobbleOctave2

      public static double quobbleOctave2(int seed, double x)
      Just gets two octaves of quobble(int, double); still has a range of -1 to 1. This tends to look much more natural than just one octave of quobble(), because the points where it always will hit 0 are spaced differently for the two octaves here.
      Parameters:
      x - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobble

      public static float quobble(long seed, float value)
      Quilez' 1D noise, with some changes to work on the CPU. Takes a distance value and any long seed, and produces a smoothly-changing result as value goes up or down and seed stays the same. Uses a quartic curve. The quartic curve means that at specific positions, each separated by an integer from each other, the noise will reliably be 0. This does not typically happen on integers for value, but it can if seed is 0 or some very high numbers.
      The distance (value) should be between -16384 and 1073733631 for this to return correct results. Because floats incur precision loss earlier than 1073733631, the actual upper bound is lower. The limit of -8192 comes from how this uses MathTools.fastFloor(float) internally on value + value.
      Parameters:
      value - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobbleOctave2

      public static float quobbleOctave2(long seed, float x)
      Just gets two octaves of quobble(long, float); still has a range of -1 to 1. This tends to look much more natural than just one octave of quobble(), because the points where it always will hit 0 are spaced differently for the two octaves here.
      Parameters:
      x - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobble

      public static double quobble(long seed, double value)
      Quilez' 1D noise, with some changes to work on the CPU. Takes a distance value and any long seed, and produces a smoothly-changing result as value goes up or down and seed stays the same. Uses a quartic curve. The quartic curve means that at specific positions, each separated by an integer from each other, the noise will reliably be 0. This does not typically happen on integers for value, but it can if seed is 0.
      Parameters:
      value - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • quobbleOctave2

      public static double quobbleOctave2(long seed, double x)
      Just gets two octaves of quobble(long, double); still has a range of -1 to 1. This tends to look much more natural than just one octave of quobble(), because the points where it always will hit 0 are spaced differently for the two octaves here.
      Parameters:
      x - should go up and/or down steadily and by small amounts (less than 1.0, certainly)
      seed - should stay the same for a given curve
      Returns:
      a noise value between -1.0 and 1.0
    • trobble

      public static double trobble(long seed, double value)
      Trigonometric wobble. Domain for value is extremely large. Range is (-1, 1).
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a double that typically changes slowly, by less than 1.0, with direction changes at integer inputs
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • trobble

      public static float trobble(long seed, float value)
      Trigonometric wobble. Domain for value is effectively [-16384, 16384]. Range is (-1, 1).
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • trobble

      public static double trobble(int seed, double value)
      Trigonometric wobble. Domain for value is extremely large. Range is (-1, 1).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a double that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random double between -1.0 and 1.0 (both exclusive), smoothly changing with value
    • trobble

      public static float trobble(int seed, float value)
      Trigonometric wobble. Domain for value is effectively [-16384, 16384]. Range is (-1, 1).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • smoothWobble

      public static float smoothWobble(int seed, float t)
      Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values. This is nearly the same as bicubicWobble(int, float), but it isn't at all as biased towards central results.
      Parameters:
      t - a distance traveled; should change by less than 1 between calls, and should be less than about 10000
      seed - any int
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • smoothWobble

      public static double smoothWobble(int seed, double t)
      Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values. This is nearly the same as bicubicWobble(int, double), but it isn't at all as biased towards central results.
      Parameters:
      t - a distance traveled; should change by less than 1 between calls
      seed - any int
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • smoothWobble

      public static float smoothWobble(long seed, float t)
      Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values. This is nearly the same as bicubicWobble(long, float), but it isn't at all as biased towards central results.
      Parameters:
      t - a distance traveled; should change by less than 1 between calls
      seed - any long
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • smoothWobble

      public static double smoothWobble(long seed, double t)
      Sway very smoothly using bicubic interpolation between 4 points (the two integers before t and the two after), and additional processing at the last step to push results closer to the min and max valid values. This is nearly the same as bicubicWobble(long, double), but it isn't at all as biased towards central results.
      Parameters:
      t - a distance traveled; should change by less than 1 between calls
      seed - any long
      Returns:
      a smoothly-interpolated swaying value between -1 and 1, both exclusive
    • wobbleAngle

      public static float wobbleAngle(long seed, float value)
      A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at pi * 2 so this can be used to get smoothly-changing random angles. Has (seeded) random peaks and valleys where it slows its range of change, but can return any value from 0 to 6.283185307179586f, or pi * 2. The pattern this will produce will be completely different if the seed changes, and the value is expected to be something other than an angle, like time. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0f and 6.283185307179586f (both inclusive), smoothly changing with value and wrapping
    • wobbleAngleDeg

      public static float wobbleAngleDeg(long seed, float value)
      A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 360.0 so this can be used to get smoothly-changing random angles. Has (seeded) random peaks and valleys where it slows its range of change, but can return any value from 0 to 360.0f . The pattern this will produce will be completely different if the seed changes, and the value is expected to be something other than an angle, like time. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0f and 360.0f (both inclusive), smoothly changing with value and wrapping
    • wobbleAngleTurns

      public static float wobbleAngleTurns(long seed, float value)
      A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 1.0 so this can be used to get smoothly-changing random angles in turns. Has (seeded) random peaks and valleys where it slows its range of change, but can return any value from 0 to 1.0. The pattern this will produce will be completely different if the seed changes, and the value is expected to be something other than an angle, like time. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 1.0f (both inclusive), smoothly changing with value and wrapping
    • wobbleAngle

      public static float wobbleAngle(int seed, float value)
      A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at pi * 2 so this can be used to get smoothly-changing random angles. Has (seeded) random peaks and valleys where it slows its range of change, but can return any value from 0 to 6.283185307179586f, or pi * 2. The pattern this will produce will be completely different if the seed changes, and the value is expected to be something other than an angle, like time. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0f and 6.283185307179586f (both inclusive), smoothly changing with value and wrapping
    • wobbleAngleDeg

      public static float wobbleAngleDeg(int seed, float value)
      A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 360.0 so this can be used to get smoothly-changing random angles. Has (seeded) random peaks and valleys where it slows its range of change, but can return any value from 0 to 360.0f . The pattern this will produce will be completely different if the seed changes, and the value is expected to be something other than an angle, like time. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0f and 360.0f (both inclusive), smoothly changing with value and wrapping
    • wobbleAngleTurns

      public static float wobbleAngleTurns(int seed, float value)
      A 1D "noise" method that produces smooth transitions like a sine wave, but also wrapping around at 1.0 so this can be used to get smoothly-changing random angles in turns. Has (seeded) random peaks and valleys where it slows its range of change, but can return any value from 0 to 1.0. The pattern this will produce will be completely different if the seed changes, and the value is expected to be something other than an angle, like time. Uses a simple method of cubic interpolation between random values, where a random value is used without modification when given an integer for value. Note that this uses a different type of interpolation than a sine wave would, and the shape here uses cubic interpolation.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 1.0f (both inclusive), smoothly changing with value and wrapping
    • splobbleAngle

      public static float splobbleAngle(int seed, float value)
      Like splobble(int, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in radians.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 6.283185307179586f (both inclusive), smoothly changing with value and wrapping
    • splobbleAngleDeg

      public static float splobbleAngleDeg(int seed, float value)
      Like splobble(int, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in degrees.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 360.0f (both inclusive), smoothly changing with value and wrapping
    • splobbleAngleTurns

      public static float splobbleAngleTurns(int seed, float value)
      Like splobble(int, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in turns.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 1.0f (both inclusive), smoothly changing with value and wrapping
    • splobbleAngle

      public static float splobbleAngle(long seed, float value)
      Like splobble(long, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in radians.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 6.283185307179586f (both inclusive), smoothly changing with value and wrapping
    • splobbleAngleDeg

      public static float splobbleAngleDeg(long seed, float value)
      Like splobble(long, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in degrees.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 360.0f (both inclusive), smoothly changing with value and wrapping
    • splobbleAngleTurns

      public static float splobbleAngleTurns(long seed, float value)
      Like splobble(long, float), this is a 1D wobble that can become more sharp or more gradual at different points on its length, but this produces a (wrapping) angle measured in turns.
      Parameters:
      seed - a long seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a float that typically changes slowly, by less than 1.0, with possible direction changes at integer inputs
      Returns:
      a pseudo-random float between 0.0f and 1.0f (both inclusive), smoothly changing with value and wrapping
    • wobbleWrapped

      public static float wobbleWrapped(long seed, float value, int modulus)
      Very similar to wobble(long, float), but only tolerates non-negative value and wraps value when it gets too close to modulus. Could find various uses when wrapping is needed. One such potential use is for looping animations; if the modulus is set so that value equals modulus (or an integer multiple of it) exactly when the animation starts and ends, the animation will then loop seamlessly, at least for anything that depends on this method.
      The wobble methods have a shape where they flatten out when value is an integer, so typically you should add a value smaller than 1 to value at each call if you want it to change smoothly. For the wrapped methods, the modulus is also the number of times the curve will flatten out over the course of a cycle.
      Note that wobbleWrapped(seed, 0, modulus) and wobbleWrapped(seed, modulus, modulus) will produce the same value as long as modulus is positive (and not large enough to incur precision loss).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a non-negative float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      modulus - where to wrap value if it gets too high; must be positive
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • wobbleWrappedTight

      public static float wobbleWrappedTight(long seed, float value, int modulus)
      Very similar to wobble(long, float), but only tolerates non-negative value and wraps value when it gets too close to modulus. Could find various uses when wrapping is needed. One such potential use is for looping animations; if the modulus is set so that value equals modulus (or an integer multiple of it) exactly when the animation starts and ends, the animation will then loop seamlessly, at least for anything that depends on this method.
      The wobble methods have a shape where they flatten out when value is an integer, so typically you should add a value smaller than 1 to value at each call if you want it to change smoothly. For the wrapped methods, the modulus is also the number of times the curve will flatten out over the course of a cycle.
      Note that wobbleWrappedTight(seed, 0, modulus) and wobbleWrappedTight(seed, modulus, modulus) will produce the same value as long as modulus is positive (and not large enough to incur precision loss).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a non-negative float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      modulus - where to wrap value if it gets too high; must be positive
      Returns:
      a pseudo-random float between 0f and 1f (both inclusive), smoothly changing with value
    • wobbleWrapped

      public static float wobbleWrapped(int seed, float value, int modulus)
      Very similar to wobble(int, float), but only tolerates non-negative value and wraps value when it gets too close to modulus. Used by generateLookupTable(int, int, int, int), but could find uses elsewhere. One such potential use is for looping animations; if the modulus is set so that value equals modulus (or an integer multiple of it) exactly when the animation starts and ends, the animation will then loop seamlessly, at least for anything that depends on this method.
      The wobble methods have a shape where they flatten out when value is an integer, so typically you should add a value smaller than 1 to value at each call if you want it to change smoothly. For the wrapped methods, the modulus is also the number of times the curve will flatten out over the course of a cycle.
      Note that wobbleWrapped(seed, 0, modulus) and wobbleWrapped(seed, modulus, modulus) will produce the same value as long as modulus is positive (and not large enough to incur precision loss).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a non-negative float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      modulus - where to wrap value if it gets too high; must be positive
      Returns:
      a pseudo-random float between -1f and 1f (both exclusive), smoothly changing with value
    • wobbleWrappedTight

      public static float wobbleWrappedTight(int seed, float value, int modulus)
      Very similar to wobble(int, float), but only tolerates non-negative value and wraps value when it gets too close to modulus. Used by generateSplineLookupTable(int, int, int, int, float, float), but could find uses elsewhere. One such potential use is for looping animations; if the modulus is set so that value equals modulus (or an integer multiple of it) exactly when the animation starts and ends, the animation will then loop seamlessly, at least for anything that depends on this method.
      The wobble methods have a shape where they flatten out when value is an integer, so typically you should add a value smaller than 1 to value at each call if you want it to change smoothly. For the wrapped methods, the modulus is also the number of times the curve will flatten out over the course of a cycle.
      Note that wobbleWrappedTight(seed, 0, modulus) and wobbleWrappedTight(seed, modulus, modulus) will produce the same value as long as modulus is positive (and not large enough to incur precision loss).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes; this should not change between calls
      value - a non-negative float that typically changes slowly, by less than 2.0, with direction changes at integer inputs
      modulus - where to wrap value if it gets too high; must be positive
      Returns:
      a pseudo-random float between 0f and 1f (both inclusive), smoothly changing with value
    • generateLookupTable

      public static float[] generateLookupTable(int seed, int size, int points, int octaves)
      Creates a wrapping lookup table of size float items for a wobbling line, using a specific count of points where the wobble can reach a peak or valley, a number of octaves to refine the wobble, and a seed.
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes
      size - how many items to have in the returned float array
      points - effectively, the frequency; how many possible peak/valley points will appear in the first octave
      octaves - a positive int that adds more detail as it goes higher; cannot be more than 31
      Returns:
      the wrapping lookup table of float values between -1 and 1
    • generateSplineLookupTable

      public static float[] generateSplineLookupTable(int seed, int size, int points, int octaves, float shape, float turning)
      Creates a wrapping lookup table of size float items for a wobbling line, using a specific count of points where the wobble can reach a peak or valley, a number of octaves to refine the wobble, and a seed. This also takes a shape and turning parameter that it uses to finish the lookup table by running every item through a call to MathTools.barronSpline(float, float, float); this can be useful to change how the noise is distributed from slightly favoring extremes (the default) to preferring central values (when shape is between 0 and 1) or preferring more extreme values (when shape is more than 1).
      Parameters:
      seed - an int seed that will determine the pattern of peaks and valleys this will generate as value changes
      size - how many items to have in the returned float array
      points - effectively, the frequency; how many possible peak/valley points will appear in the first octave
      octaves - a positive int that adds more detail as it goes higher; cannot be more than 31
      shape - must be greater than or equal to 0; values greater than 1 are "normal interpolations"
      turning - a value between 0.0 and 1.0, inclusive, where the shape changes
      Returns:
      the wrapping lookup table of float values between 0 and 1, both inclusive