Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

trigonometry math functions

I have been studying the rolling interface, which does not seem to support a mechanic needed by the shooting rules in my home-brew games system. Specifically, in this system, a test is used to determine how far a shot deviates from the point aimed at, as a function of the distance to the target, in the form: deviation = Range X TAN(ROLL) Although the interface supports certain math functions, I don't see TAN. Is there any way of implementing this? Thanks Mark
1425747546
Ada L.
Marketplace Creator
Sheet Author
API Scripter
You would need to create a custom dice rolling API script to handle trig functions.
1425766998
Pat S.
Forum Champion
Sheet Author
The API script (javascripting) is a mentor level feature. The normal dice roller would not handle what you are wanting.
Can you not code using variables and rolls with the API script? Because you could create an approximation to work with using Taylor Series. I don't remember if there's an easier way to calculate tangent... but approximating sine or cosine is pretty easy. (x is in radians not degrees) sin(x) = x - x^3/3! + x^5/5! - x^7/7! cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! tan(x) = sin(x)/cos(x) If you need to convert a roll that's in degrees to radians, x = (roll)*pi/180 I tested this out on a graphing calculator and it's basically the exact same thing as tan(x) from -pi < x < pi (which is the only range you need)
Hi Mark, Thanks for your interesting suggestion. Your message appears to suggest that I use the Tayor Series approximation in an API script, in which case, why wouldn't I just use the standard Javascript math.tan() function? Or maybe you meant that the taylor function would allow me to approximate TAN using rolling engine macros, despite the absence of trig functions- is that what you meant, and if not, is there some reason that this would not be possible? Thanks again for your help Mark
1425804077

Edited 1425804435
Mark, Before there were calculators that could do the math with precision; the military relied on tables that listed the varying angles and their corresponding functions as found in <a href="http://math2.org/math/trig/tables.htm" rel="nofollow">http://math2.org/math/trig/tables.htm</a> . You may be able to utilize Roll20 to reference angle measurements and report the function values and still be within 4 significant digits. I hope that's sufficient.
Hi Trevor, Thanks for your suggestion. That may well be an acceptable solution, especially since there are obviously a finite number of possible dice rolls. Is there a way to make the rolling engine retrieve a value from a look-up table of the kind you mention, or does this approach still rely on javasript/api? Mark
I don't have access to the API scripts currently, so I don't know what they're capable of. I'm just offering a mathematical alternative to the problem. Hopefully, you can find some method that works for you :) I spent some time messing around with the macros, and it doesn't look like factorials or exponentials are easy to implement either.
1425843194
Gen Kitty
Forum Champion
Mark M. said: Hi Trevor, Thanks for your suggestion. That may well be an acceptable solution, especially since there are obviously a finite number of possible dice rolls. Is there a way to make the rolling engine retrieve a value from a look-up table of the kind you mention, or does this approach still rely on javasript/api? Mark <a href="https://wiki.roll20.net/Card_Decks_and_Rollable_Tables#Rollable_Tables" rel="nofollow">https://wiki.roll20.net/Card_Decks_and_Rollable_Tables#Rollable_Tables</a> are available to anyone :)
1425843288
Lithl
Pro
Sheet Author
API Scripter
Mark M. said: Is there a way to make the rolling engine retrieve a value from a look-up table Rollable tables? =)