
I know that https://app.roll20.net/forum/post/1242264/min-x-y-... is asking for the min and max function, but we need more than just those. And not everything can be done with workarounds like the min and max functions can.
I am posting this on behalf of Windsor M. (who can't) since he was trying to help me with max-load calculations for encumbrance on the D&D3.5 sheet. The big math function we need is a power function (a^b) and since the b is a derived variable based on the starting strength skill, we could not come up with a workaround.
So:
There are some things we simply cannot calculate with linear functions. For example, this:
is not a linear function. It replicates (exactly) a table of values, and while the formula behind it has been broken down into round(n), ceil(n), floor(n) and abs(n) ... it still requires one (unavoidable) use of the pow(a, b) function with a static base and a variable exponent.
My suggestion is that we expand the available math functions. A few key ones are: log, exponential, max, min, sin, cos. With those building block functions most others can be derived. With that being said, it might not be a bad idea to include native functions for some of the common derivable functions.
Below is a list of functions showing their JavaScript calls followed by some possible syntax in roll20.
Power, Exponential, & Log Functions:
Pick functions:
Trig functions:
With more math tools available, not only would character-sheet builders benefit, but macros would get a boon as well!
I am posting this on behalf of Windsor M. (who can't) since he was trying to help me with max-load calculations for encumbrance on the D&D3.5 sheet. The big math function we need is a power function (a^b) and since the b is a derived variable based on the starting strength skill, we could not come up with a workaround.
So:
There are some things we simply cannot calculate with linear functions. For example, this:

is not a linear function. It replicates (exactly) a table of values, and while the formula behind it has been broken down into round(n), ceil(n), floor(n) and abs(n) ... it still requires one (unavoidable) use of the pow(a, b) function with a static base and a variable exponent.
My suggestion is that we expand the available math functions. A few key ones are: log, exponential, max, min, sin, cos. With those building block functions most others can be derived. With that being said, it might not be a bad idea to include native functions for some of the common derivable functions.
Below is a list of functions showing their JavaScript calls followed by some possible syntax in roll20.
Power, Exponential, & Log Functions:
Math.log(n) = ln(n) Math.exp(n) = e^n = exp(n) Math.pow(a,b) = Math.exp(Math.log(a)*b) = a^b = pow(a, b) Math.log(n)/Math.log(b) = log[b](n) = log(b, n) Math.pow(n, 1/r) = n^(1/r) = nroot(r, n) Math.sqrt(n) = Math.pow(n, 1/2) = n^(1/2) = sqrt(n)
As you can see above, even many of the other functions in Math can be derived from these 2 building block functions.
Pick functions:
Math.max(a, b, ...) = max(a, b) Math.min(a, b, ...) = min(a, b)
Even if it only picks between two numbers it is an extraordinarily useful tool to have. This portion of the suggestion mirrors: https://app.roll20.net/forum/post/1242264/min-x-y-and-max-x-y-functions#post-1845953
Trig functions:
Math.sin(t), Math.cos(t)These are the most important trig functions, practically everything else can be built from them. I don't think we'd need their inverses, but the Math object in JavaScript does have those (perhaps Math.atan2(a, b) would be handy, since we don't have conditionals)
With more math tools available, not only would character-sheet builders benefit, but macros would get a boon as well!