Trigonometry

by Oasiscircle
Basic trigonometric functions that aren't offered in BYOND! [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Oasiscircle.Trigonometry##version=2

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Oasiscircle.Trigonometry##version=2

124 downloads
Version 1.2
Date added: May 13 2011
Last updated: May 15 2011
0 fans
Include the following trigonometric procedures by simply checking the include-box!

Version 1.0 (359 bytes)
*Added all basic functions.

Version 1.1 (401 bytes)
*Added arctan2() function.
*Fixed arcpyth() function.

Version 1.2 (424 bytes)
*Uncompressed for cross-eyes sake. :)

pyth(a,b) return sqrt(a**2+b**2)
arcpyth(a,c) return sqrt(c**2-a**2)
triarea(a,b,C) return (a*b*sin(C))/2
tan(n) return sin(n) / cos(n)
cot(n) return cos(n) / sin(n)
sec(n) return 1 / cos(n)
csc(n) return 1 / sin(n)
arctan(n) return arccos(1 / sqrt(1+n*n))
arccot(n) return arcsin(1 / sqrt(1+n*n))
arcsec(n) return arccos(1 / n)
arccsc(n) return arcsin(1 / n)
arctan2(x,y) return 2*arctan(y/(sqrt(x**2+y**2)+x))


Code is compressed to smallest size (424 bytes!) in order to have the smallest effect possible on your projects! (:

                   Profile results (total time)
Proc Name Self CPU Total CPU Real Time Calls
-------------- --------- --------- --------- ---------
/proc/arctan 1.185 1.319 1.600 2000000
/proc/pyth 0.687 0.753 0.915 1000000
/proc/arcpyth 0.678 0.742 0.881 1000000
/proc/arccsc 0.608 0.676 0.816 1000000
/proc/arcsec 0.605 0.668 0.804 1000000
/proc/arccot 0.564 0.629 0.782 1000000
/proc/triarea 0.444 0.523 0.666 1000000
/proc/cot 0.379 0.445 0.611 1000000
/proc/tan 0.370 0.424 0.585 1000000
/proc/csc 0.255 0.326 0.498 1000000
/proc/sec 0.250 0.321 0.473 1000000