From e6561e6f2276663caf1181a77c5dbe2fde9797e7 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Fri, 29 May 2009 05:16:49 +0000 Subject: fix [atan2] svn path=/trunk/; revision=11559 --- desiredata/src/builtins.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/desiredata/src/builtins.c b/desiredata/src/builtins.c index a036df65..b1547ab9 100644 --- a/desiredata/src/builtins.c +++ b/desiredata/src/builtins.c @@ -1172,29 +1172,13 @@ static int mydiv(int a, int b) { } BINOP(binop_mydiv, (float)mydiv((int)a,(int)b)) +BINOP(binop_atan2, (a==0 && b==0 ? 0 : atan2f(a,b))); + FUNC1(sin,sinf(a)) FUNC1(cos,cosf(a)) FUNC1(tan,tanf(a)) FUNC1(atan,atanf(a)) -static t_class *atan2_class; -struct t_atan2 : t_object { - float f; -}; -static void *atan2_new() { - t_atan2 *x = (t_atan2 *)pd_new(atan2_class); - static int warned; - if (!warned) post("warning: atan2 inlets switched from Pd 0.37 to 0.38"), warned=1; - floatinlet_new(x, &x->f); - x->f = 0; - outlet_new(x, &s_float); - return x; -} -static void atan2_float(t_atan2 *x, t_float f) { - float r = (f == 0 && x->f == 0 ? 0 : atan2f(f, x->f)); - outlet_float(x->outlet, r); -} - FUNC1(sqrt,sqrtf(a)) FUNC1(log, a>0 ? logf(a) : -1000) FUNC1(exp,expf(min(a,87.3365f))) @@ -1251,6 +1235,7 @@ void arithmetic_setup() { BINOPDECL(binop_pc,"%") BINOPDECL(binop_mymod,"mod") BINOPDECL(binop_mydiv,"div") + BINOPDECL(binop_atan2,"atan2"); s = gensym("math"); @@ -1263,7 +1248,6 @@ void arithmetic_setup() { FUNCDECL(cos,"cos"); FUNCDECL(tan,"tan"); FUNCDECL(atan,"atan"); - FUNCDECL(atan2,"atan2"); /* actually a binop */ FUNCDECL(sqrt,"sqrt"); FUNCDECL(log,"log"); FUNCDECL(exp,"exp"); -- cgit v1.2.1