Skip to content

List of periodic functions normalized to 0..1 range

Notifications You must be signed in to change notification settings

scijs/periodic-function

Repository files navigation

periodic-function unstable Build Status

Collection of periodic functions with period normalized to turns.

Usage

npm install periodic-function

const fn = require('periodic-function/<fn>')

//π radians
let halfTurn = fn(.5)

//2π radians
let fullTurn = fn(1)

API

let fn = require('periodic-function/<fn>')

The fn takes the amount of turn t as the first argument and optional parameters. The list of available functions:

Signature Waveform Meaning
sine(t, phase=0) sine Math.sin normalized to 0..1 rather than radians 0..2π. To turn into cos, set phase=.25.
triangle(t, ratio=0.5) triangle Triangular waveform with regulated ratio. To turn into sawtooth set ratio=0 or ratio=1.
sawtooth(t, inverse=false) sawtooth Edge case of triangular waveform, whether descending or ascending.
square(t, ratio=0.5) square Rectangular waveform with regulated ratio. To turn into pulse set ratio=0.
pulse(t, tlr=0) pulse Delta-pulse, which is 1 at 0 and 0 anywhere else. Pass tlr as a precision tolerance, ie. 1e-5.
fourier(t, real, imag?, normalize=false) fourier Fourier Series coefficients, ie. harmonics. 0 harmonic is static level, 1st is base frequency, 2nd is double base frequency, 3rd is triple etc. Set normalize=true to bring max harmonic to 1.
clausen(t, limit=10) clausen Clausen function. Pass limit to indicate number of iterations, precision/performance tradeoff.
step(t, samples) step Step function, picks closest sample value out of a set.
interpolate(t, samples) interpolate Interpolates between closest values in a sample set.
noise(t) noise Repeated sample of noise.

If you feel like it is not complete list of you know example of a good periodic function, suitable for dsp, welcome to contribute.

Related

Credits

© 2017 Dima Yv. MIT License

About

List of periodic functions normalized to 0..1 range

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published