bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

atan hooks for atan2


From: Wolfgang Rupprecht
Subject: atan hooks for atan2
Date: Sat, 16 Feb 2002 13:44:19 -0800 (PST)

This patch adds hooks for calling atan2 if the lisp atan function is
invoked with 2 args.  This patch is necessary if one wants to use atan
to determine the compass direction of a positional shift given a
delta-X and delta-Y.  Without it, all answers are folded into the
range -pi/2, +pi/2.

(This patch is being released under the GPL, yada, yada, yada).

-wolfgang

cd /usr/pkgsrc/editors/emacs/work/emacs-20.7/src/
diff -u /usr/pkgsrc/editors/emacs/work/emacs-20.7/src/floatfns.c.\~1\~ 
/usr/pkgsrc/editors/emacs/work/emacs-20.7/src/floatfns.c
--- /usr/pkgsrc/editors/emacs/work/emacs-20.7/src/floatfns.c.~1~        Tue Apr 
14 05:29:27 1998
+++ /usr/pkgsrc/editors/emacs/work/emacs-20.7/src/floatfns.c    Sat Feb 16 
13:20:23 2002
@@ -256,13 +256,21 @@
   return make_float (d);
 }
 
-DEFUN ("atan", Fatan, Satan, 1, 1, 0,
-  "Return the inverse tangent of ARG.")
-  (arg)
+DEFUN ("atan", Fatan, Satan, 1, 2, 0,
+       "Return the inverse tangent of Y_divided_by_X.\n\
+If second optional are is given, return the inverse tangent of Y and X")
+  (arg, arg2)
      register Lisp_Object arg;
 {
   double d = extract_float (arg);
-  IN_FLOAT (d = atan (d), "atan", arg);
+  
+  if (NILP (arg2))
+    IN_FLOAT (d = atan (d), "atan", arg);      
+  else
+    {
+      double d2 = extract_float (arg2);
+      IN_FLOAT2 (d = atan2 (d, d2), "atan", arg, arg2);
+    }
   return make_float (d);
 }
 

Diff finished at Sat Feb 16 13:22:11

-- 
Wolfgang Rupprecht    <address@hidden>     http://www.wsrcc.com/wolfgang/
Coming soon: GPS mapping tools for Open Systems. http://www.gnomad-mapping.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]