Function interpolateNumber

  • Given an Array of numbers, estimate the resulting number, at a t value between 0 to 1

    Basic interpolation works by scaling t from 0 - 1, to some start number and end number, in this case lets use 0 as our start number and 100 as our end number, so, basic interpolation would interpolate between 0 to 100.

    If we use a t of 0.5, the interpolated value between 0 to 100, is 50. interpolateNumber takes it further, by allowing you to interpolate with more than 2 values, it allows for multiple values. E.g. Given an Array of values [0, 100, 0], and a t of 0.5, the interpolated value would become 100.

    Based on d3.interpolateBasis [https://github.com/d3/d3-interpolate#interpolateBasis], check out the link above for more detail.

    Source

    Source code of interpolateNumber

    Parameters

    • t: number

      A number between 0 to 1

    • values: number[]

      Array of numbers to interpolate between

    • decimal: number = 3

      How many decimals should the interpolated value have

    Returns number

    Interpolated number at instant t

Generated using TypeDoc