From ad90437089281d703726a40095bda76419290cfd Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Thu, 23 Feb 2023 10:12:56 -0500 Subject: [PATCH] add more important math functions --- mods/code_library.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mods/code_library.js b/mods/code_library.js index c3323571..a01db5d1 100644 --- a/mods/code_library.js +++ b/mods/code_library.js @@ -284,6 +284,22 @@ return number1 + number2 } + //Logistic curve + //x = real number + //L = maximum value + //x_0 = "the x value of the sigmoid midpoint" i.e. the x center of the bendy part + //k = steepness + function logisticCurve(x,L,k,x0) { + return L/( 1 + ( Math.E ** ( -k * (x - x0) ) ) ); + }; + + // https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers + // Function from August Miller + //Map a range of numbers to another range of numbers + function scale (number, inMin, inMax, outMin, outMax) { + return (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; + } + //Color function rgbStringToUnvalidatedObject(string) { //turns rgb() to {r,g,b} with no bounds checking