aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-04 10:52:09 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-04 10:52:09 -0300
commite0621e6115366f2cd041aa118df145d6c9ba5965 (patch)
tree7e144a5650a63b5c2115a627c0c65f05c7c209e3
parent38411aa102e926ee6e0d9a13ab7c233bf865ddab (diff)
downloadlua-e0621e6115366f2cd041aa118df145d6c9ba5965.tar.gz
lua-e0621e6115366f2cd041aa118df145d6c9ba5965.tar.bz2
lua-e0621e6115366f2cd041aa118df145d6c9ba5965.zip
new function "atan2".
-rw-r--r--mathlib.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/mathlib.c b/mathlib.c
index 5f87a7fb..f7f348e1 100644
--- a/mathlib.c
+++ b/mathlib.c
@@ -3,7 +3,7 @@
3** Mathematics library to LUA 3** Mathematics library to LUA
4*/ 4*/
5 5
6char *rcs_mathlib="$Id: mathlib.c,v 1.9 1995/02/06 19:36:43 roberto Exp roberto $"; 6char *rcs_mathlib="$Id: mathlib.c,v 1.10 1995/10/02 17:03:33 roberto Exp roberto $";
7 7
8#include <stdio.h> /* NULL */ 8#include <stdio.h> /* NULL */
9#include <math.h> 9#include <math.h>
@@ -112,6 +112,19 @@ static void math_atan (void)
112} 112}
113 113
114 114
115static void math_atan2 (void)
116{
117 int d1, d2;
118 lua_Object o1 = lua_getparam (1);
119 lua_Object o2 = lua_getparam (2);
120 if (!lua_isnumber(o1) || !lua_isnumber(o2))
121 lua_error ("incorrect arguments to function `atan2'");
122 d1 = (int) lua_getnumber(o1);
123 d2 = (int) lua_getnumber(o2);
124 lua_pushnumber (TODEGREE(atan2(d1, d2)));
125}
126
127
115static void math_ceil (void) 128static void math_ceil (void)
116{ 129{
117 double d; 130 double d;
@@ -302,6 +315,7 @@ void mathlib_open (void)
302 lua_register ("asin", math_asin); 315 lua_register ("asin", math_asin);
303 lua_register ("acos", math_acos); 316 lua_register ("acos", math_acos);
304 lua_register ("atan", math_atan); 317 lua_register ("atan", math_atan);
318 lua_register ("atan2", math_atan2);
305 lua_register ("ceil", math_ceil); 319 lua_register ("ceil", math_ceil);
306 lua_register ("floor", math_floor); 320 lua_register ("floor", math_floor);
307 lua_register ("mod", math_mod); 321 lua_register ("mod", math_mod);