• Returns the value of the oscillation between a and b at time t.

    Parameters

    • a: number

      The minimium value of the oscillation

    • b: number

      The maximum value of the oscillation

    • t: number

      The time

    • Optional p: number = 1

      The period (must be nonzero)

    • Optional f: ((x) => number) = Math.cos

      The periodic function (its period must be 2π)

        • (x): number
        • Parameters

          • x: number

          Returns number

    Returns number

    ((b - a) * (f(2π * t / p) + 1) / 2) + a