From e901873f62d292e972f9307c0d6cff2c3b0bb70c Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 23 Mar 2022 04:50:41 -0500 Subject: [PATCH] chore: doc --- packages/math/src/math.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/math/src/math.js b/packages/math/src/math.js index 1577fd2..2f5c98b 100644 --- a/packages/math/src/math.js +++ b/packages/math/src/math.js @@ -178,6 +178,12 @@ export const randomNumber = (min, max) => { // smooth(er)?step assumes unit export const smoothstep = (x) => x * x * (3 - 2 * x); export const smootherstep = (x) => x * x * x * (x * (x * 6 - 15) + 10); +/** + * Probabilistic behavior. Every `period` seconds, return `true`. + * + * @param {Number} elapsed The time that's passed. + * @param {Number} period The frequency of probabilistic behavior. + */ export const spontaneous = (elapsed, period) => Math.random() < 1 / (period / elapsed); export const sub = (l, r) => l - r; export const toRad = (a) => a * PI_180;