add more important math functions

This commit is contained in:
Laetitia (O-01-67) 2023-02-23 10:12:56 -05:00 committed by GitHub
parent 7d2728d39a
commit ad90437089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -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