Cerberus X Documentation

Module cerberus.interpolate

Functions to interpolate between two values. More...

Declarations

Imported By
cerberus
Please note that only documented modules are listed here, there might be undocumented modules that import this one.
Functions
InterpolateCubicBezier : Float ( y0:Float, y1:Float, A:Float, B:Float, C:Float, D:Float, x:Float, pPrecision:Float=0.0001 ) Interpolates on a cubic bézier curve from (0,y0) to (1,y1) with control points (A,B) and (C,D) at x.
InterpolateCurve : Float ( y0:Float, y1:Float, yA:Float, x:Float ) Interpolates on a curve from (0,y0) to (1,y1) going through (0.5,yA) at x.
InterpolateFit : Float ( y0:Float, y1:Float, s0:Float, s1:Float, x:Float ) Interpolates on a curve from (0,y0) to (1,y1) with slopes s0 and s1 respectively at x.
InterpolateFlats : Float ( y0:Float, y1:Float, yA:Float, x:Float ) Interpolates on a curve from (0,y0) to (1,y1) with slopes=0 going through (0.5,yA) at x.
InterpolateLin : Float ( y0:Float, y1:Float, x:Float ) Interpolates linearly between (0,y0) and (1,y1) at x.
InterpolateSin : Float ( y0:Float, y1:Float, x:Float ) Interpolates on a sinusoidal from (0,y0) to (1,y1) at x.
LinMap : Float ( dt:Float, t0:Float, t1:Float ) Returns percentage of where about dt is in the range of t0 to t1.

Detailed Discussion

Functions to interpolate between two values. This is mostly used for timed transitions or to ease movements' beginnings and endings.

Try the Live demo


Functions Documentation

Function InterpolateCubicBezier : Float ( y0:Float, y1:Float, A:Float, B:Float, C:Float, D:Float, x:Float, pPrecision:Float=0.0001 )

Interpolates on a cubic bézier curve from (0,y0) to (1,y1) with control points (A,B) and (C,D) at x.

InterpolateCubicBezier diagram

Parameters
  • y0 - value at x=0.0
  • y1 - value at x=1.0
  • A, B, C, D - cubic bézier points
  • x - point to interpolate, ranging from 0 to 1
  • pPrecision (optional) - to which precision the x value shall be evaluated
      Returns

      Interpolated y value at x

      See also

      Live demo

      Function InterpolateCurve : Float ( y0:Float, y1:Float, yA:Float, x:Float )

      Interpolates on a curve from (0,y0) to (1,y1) going through (0.5,yA) at x.

      InterpolateCurve diagram

      Parameters
      • y0 - value at x=0.0
      • y1 - value at x=1.0
      • yA - value at x=0.5
      • x - point to interpolate, ranging from 0 to 1
          Returns

          Interpolated y value at x

          See also

          Live demo

          Function InterpolateFit : Float ( y0:Float, y1:Float, s0:Float, s1:Float, x:Float )

          Interpolates on a curve from (0,y0) to (1,y1) with slopes s0 and s1 respectively at x.

          InterpolateFit diagram

          Parameters
          • y0 - value at x=0.0
          • y1 - value at x=1.0
          • s0 - slope at x=0.0
          • s1 - slope at x=1.0
          • x - point to interpolate, ranging from 0 to 1
              Returns

              Interpolated y value at x

              See also

              Live demo

              Function InterpolateFlats : Float ( y0:Float, y1:Float, yA:Float, x:Float )

              Interpolates on a curve from (0,y0) to (1,y1) with slopes=0 going through (0.5,yA) at x.

              InterpolateFlats diagram

              Parameters
              • y0 - value at x=0.0
              • y1 - value at x=1.0
              • yA - value at x=0.5
              • x - point to interpolate, ranging from 0 to 1
                  Returns

                  Interpolated y value at x

                  See also

                  Live demo

                  Function InterpolateLin : Float ( y0:Float, y1:Float, x:Float )

                  Interpolates linearly between (0,y0) and (1,y1) at x.

                  InterpolateLin diagram

                  Parameters
                  • y0 - value at x=0.0
                  • y1 - value at x=1.0
                  • x - point to interpolate, ranging from 0 to 1
                      Returns

                      Interpolated y value at x

                      See also

                      LinMap, Live demo

                      Function InterpolateSin : Float ( y0:Float, y1:Float, x:Float )

                      Interpolates on a sinusoidal from (0,y0) to (1,y1) at x.

                      InterpolateSin diagram

                      Parameters
                      • y0 - value at x=0.0
                      • y1 - value at x=1.0
                      • x - point to interpolate, ranging from 0 to 1
                          Returns

                          Interpolated y value at x

                          See also

                          Live demo

                          Function LinMap : Float ( dt:Float, t0:Float, t1:Float )

                          Returns percentage of where about dt is in the range of t0 to t1. This is basically the inverse function of InterpolateLin.