Package toxi.math

Class ExponentialInterpolation

java.lang.Object
toxi.math.ExponentialInterpolation
All Implemented Interfaces:
InterpolateStrategy

public class ExponentialInterpolation extends Object implements InterpolateStrategy
Exponential curve interpolation with adjustable exponent. Use exp in the following ranges to achieve these effects:
  • 0.0 < x < 1.0 : ease in (steep changes towards b)
  • 1.0 : same as LinearInterpolation
  • > 1.0 : ease-out (steep changes from a)
  • Constructor Details

    • ExponentialInterpolation

      public ExponentialInterpolation()
      Default constructor uses square parabola (exp=2)
    • ExponentialInterpolation

      public ExponentialInterpolation(float exp)
      Parameters:
      exp - curve exponent
  • Method Details

    • interpolate

      public double interpolate(double a, double b, double f)
      Description copied from interface: InterpolateStrategy
      Implements an interpolation equation using double precision values.
      Specified by:
      interpolate in interface InterpolateStrategy
      Parameters:
      a - current value
      b - target value
      f - normalized interpolation factor (0.0 .. 1.0)
      Returns:
      interpolated value
    • interpolate

      public float interpolate(float a, float b, float f)
      Description copied from interface: InterpolateStrategy
      Implements an interpolation equation using float values.
      Specified by:
      interpolate in interface InterpolateStrategy
      Parameters:
      a - current value
      b - target value
      f - normalized interpolation factor (0.0 .. 1.0)
      Returns:
      interpolated value