1
0
Fork 0
fgdata/Nasal/math.nas
andy 3bcfb0624a Add soft-coded utilites to the "io" and "math" modules. The math
stuff is, for the most part, already available in the geo module; but
it's small and this naming matches the evolvoing "standard nasal
library".
2007-03-29 22:09:25 +00:00

15 lines
399 B
Text

var abs = func(n) { n < 0 ? -n : n }
var pow = func(x, y) { exp(y * ln(x)) }
var mod = func(n, m) {
var x = n - m * int(n/m); # int() truncates to zero, not -Inf
return x < 0 ? x + abs(m) : x; # ...so must handle negative n's
}
var asin = func(y) { atan2(y, sqrt(1-y*y)) }
var acos = func(x) { atan2(sqrt(1-x*x), x) }
var _iln10 = 1/ln(10);
var log10 = func(x) { ln(x) * _iln10; }