Skip to content

Commit

Permalink
feat(math): add gaussian()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 10, 2020
1 parent 07a278f commit 138befe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/math/src/mix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,16 @@ export const schlick: FnN3 = (a, b, t) =>
* @param num
*/
export const expFactor: FnN3 = (a, b, num) => (b / a) ** (1 / num);

/**
* Computes gaussian bell curve for given center `bias` and `sigma` (spread).
*
* @remarks
* Interactive graph: https://www.desmos.com/calculator/aq6hdzxprv
*
* @param bias
* @param sigma
* @param t
*/
export const gaussian: FnN3 = (bias, sigma, t) =>
Math.exp(-((t - bias) ** 2) / (2 * sigma * sigma));

0 comments on commit 138befe

Please sign in to comment.