lua

A copy of the Lua development repository
Log | Files | Refs | README

commit e0621e6115366f2cd041aa118df145d6c9ba5965
parent 38411aa102e926ee6e0d9a13ab7c233bf865ddab
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed,  4 Oct 1995 10:51:50 -0300

new function "atan2".

Diffstat:
Mmathlib.c | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/mathlib.c b/mathlib.c @@ -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);