new function "atan2".

This commit is contained in:
Roberto Ierusalimschy 1995-10-04 10:52:09 -03:00
parent 38411aa102
commit e0621e6115
1 changed files with 15 additions and 1 deletions

View File

@ -3,7 +3,7 @@
** Mathematics library to LUA
*/
char *rcs_mathlib="$Id: mathlib.c,v 1.9 1995/02/06 19:36:43 roberto Exp roberto $";
char *rcs_mathlib="$Id: mathlib.c,v 1.10 1995/10/02 17:03:33 roberto Exp roberto $";
#include <stdio.h> /* NULL */
#include <math.h>
@ -112,6 +112,19 @@ static void math_atan (void)
}
static void math_atan2 (void)
{
int d1, d2;
lua_Object o1 = lua_getparam (1);
lua_Object o2 = lua_getparam (2);
if (!lua_isnumber(o1) || !lua_isnumber(o2))
lua_error ("incorrect arguments to function `atan2'");
d1 = (int) lua_getnumber(o1);
d2 = (int) lua_getnumber(o2);
lua_pushnumber (TODEGREE(atan2(d1, d2)));
}
static void math_ceil (void)
{
double d;
@ -302,6 +315,7 @@ void mathlib_open (void)
lua_register ("asin", math_asin);
lua_register ("acos", math_acos);
lua_register ("atan", math_atan);
lua_register ("atan2", math_atan2);
lua_register ("ceil", math_ceil);
lua_register ("floor", math_floor);
lua_register ("mod", math_mod);