Trigonometry Library
Trigonometry for those who feel the default trig functions offered by BYOND aren't enough for their projects!
This library includes the following procs!
pyth(a,b)
Pythagorean Theorum, input the two lengths of a right triangle and the hypotenuse is returned.
arcpyth(a,c)
Reverse Pythagorean Theorum, input one known length and the hypotenuse of a right triangle and the unknown length is returned.
triarea(a,b,C)
Area of a Triange, input two known lengths and the measure of the angle opposite to the unknown length and the area of the triangle if returned.
tan(n)
Tangent, input value in degrees and receive the ratio of sine divided by cosine of the angle measure.
And now some of the more commonly known ones.
cot(n) 1/tan(n)
sec(n) 1/cos(n)
csc(n) 1/sin(n)
arctan(n) arccos(1 / sqrt(1+n*n))
arccot(n) arcsin(1 / sqrt(1+n*n))
arcsec(n) arccos(1 / n)
arccsc(n) arcsin(1 / n)
Also, I've updated Delve a bit. I added in triggers and I made a arrow/bow weapon. I've also started writing about in-game classes. No video today, sorry! D:
May 14 2011, 8:02 pm
|
|
Ah sweet finally!
|
I might also make deg2rad() and rad2deg() if those are actually wanted, because radians can actually be helpful at some points. (:
|
The more the merrier dude. I like to collect every piece of code I find, you never know what's going to help you out.
|
Toadfish wrote:
sqrt(a**2-c**2) => sqrt(c**2-a**2) Hmmm, in what language does '**' mean to the power of? Never seen that before...0_0 |
Mecha Destroyer JD wrote:
Hmmm, in what language does '**' mean to the power of? Never seen that before...0_0 DM, hahaha ;) Most languages use a function (pow) instead of the ^ operator, because the carat is more traditionally used for bitwise XOR. I guess Dantom decided power was basic enough that it deserved an operator too. Back to the OP, you should add a get_angle(dx,dy) process, that takes the quadrant into account when returning the angle. It's a very handy function. |
DarkCampainger wrote:
Back to the OP, you should add a get_angle(dx,dy) process, that takes the quadrant into account when returning the angle. For a math library, the name "atan2" is probably better. Or, in this case, arctan2. |
Forum_account wrote:
DarkCampainger wrote: I added arctan2() to the library along with fixing the arcpyth() function. (: |
Huh, thank you. I'll likely only end up using tan and pyth, but that will save quite a bit of typing.
|