diff src/paranormal/libcalc/function.c @ 334:a9f1bd76a3e6 trunk

[svn] - apply_xform(): check for NULL vfield (broken scripts) - add tan(), asin(), acos(), atan(), log() to script engine.
author nenolod
date Tue, 05 Dec 2006 03:40:04 -0800
parents 3e160f6c04d2
children 7ae024f5d91b
line wrap: on
line diff
--- a/src/paranormal/libcalc/function.c	Tue Dec 05 02:16:09 2006 -0800
+++ b/src/paranormal/libcalc/function.c	Tue Dec 05 03:40:04 2006 -0800
@@ -33,6 +33,10 @@
 
 /* */
 
+static double f_log (ex_stack *stack) {
+  return log (pop (stack));
+}
+
 static double f_sin (ex_stack *stack) {
   return sin (pop (stack));
 }
@@ -41,6 +45,22 @@
   return cos (pop (stack));
 }
 
+static double f_tan (ex_stack *stack) {
+  return tan (pop (stack));
+}
+
+static double f_asin (ex_stack *stack) {
+  return asin (pop (stack));
+}
+
+static double f_acos (ex_stack *stack) {
+  return acos (pop (stack));
+}
+
+static double f_atan (ex_stack *stack) {
+  return atan (pop (stack));
+}
+
 static double f_if (ex_stack *stack) {
   double a = pop (stack);
   double b = pop (stack);
@@ -58,6 +78,11 @@
 static const func_t init[] = {
   { "sin", f_sin },
   { "cos", f_cos },
+  { "tan", f_tan },
+  { "asin", f_asin },
+  { "acos", f_acos },
+  { "atan", f_atan },
+  { "log", f_log },
   { "if", f_if },
   { "div", f_div }
 };