comparison 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
comparison
equal deleted inserted replaced
333:afc61c0efc05 334:a9f1bd76a3e6
31 double (*funcptr)(ex_stack *stack); 31 double (*funcptr)(ex_stack *stack);
32 } func_t; 32 } func_t;
33 33
34 /* */ 34 /* */
35 35
36 static double f_log (ex_stack *stack) {
37 return log (pop (stack));
38 }
39
36 static double f_sin (ex_stack *stack) { 40 static double f_sin (ex_stack *stack) {
37 return sin (pop (stack)); 41 return sin (pop (stack));
38 } 42 }
39 43
40 static double f_cos (ex_stack *stack) { 44 static double f_cos (ex_stack *stack) {
41 return cos (pop (stack)); 45 return cos (pop (stack));
46 }
47
48 static double f_tan (ex_stack *stack) {
49 return tan (pop (stack));
50 }
51
52 static double f_asin (ex_stack *stack) {
53 return asin (pop (stack));
54 }
55
56 static double f_acos (ex_stack *stack) {
57 return acos (pop (stack));
58 }
59
60 static double f_atan (ex_stack *stack) {
61 return atan (pop (stack));
42 } 62 }
43 63
44 static double f_if (ex_stack *stack) { 64 static double f_if (ex_stack *stack) {
45 double a = pop (stack); 65 double a = pop (stack);
46 double b = pop (stack); 66 double b = pop (stack);
56 /* */ 76 /* */
57 77
58 static const func_t init[] = { 78 static const func_t init[] = {
59 { "sin", f_sin }, 79 { "sin", f_sin },
60 { "cos", f_cos }, 80 { "cos", f_cos },
81 { "tan", f_tan },
82 { "asin", f_asin },
83 { "acos", f_acos },
84 { "atan", f_atan },
85 { "log", f_log },
61 { "if", f_if }, 86 { "if", f_if },
62 { "div", f_div } 87 { "div", f_div }
63 }; 88 };
64 89
65 int function_lookup (const char *name) { 90 int function_lookup (const char *name) {