commit 82ceb12b7af8411e543ac8672a4d5ad4652de0fc
parent 87dded936378cd57c18b58a4720b4708e01679fc
Author: Waldemar Celes <celes@tecgraf.puc-rio.br>
Date: Tue, 11 Oct 1994 10:06:28 -0300
Implementacao das funcoes para conversao de angulos rad r deg.
Diffstat:
1 file changed, 27 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.2 1994/07/20 22:12:27 celes Exp celes $";
+char *rcs_mathlib="$Id: mathlib.c,v 1.3 1994/08/15 14:13:44 celes Exp celes $";
#include <stdio.h> /* NULL */
#include <math.h>
@@ -252,6 +252,30 @@ static void math_exp (void)
lua_pushnumber (exp(d));
}
+static void math_deg (void)
+{
+ float d;
+ lua_Object o = lua_getparam (1);
+ if (o == NULL)
+ { lua_error ("too few arguments to function `deg'"); return; }
+ if (!lua_isnumber(o))
+ { lua_error ("incorrect arguments to function `deg'"); return; }
+ d = lua_getnumber(o);
+ lua_pushnumber (d*180./PI);
+}
+
+static void math_rad (void)
+{
+ float d;
+ lua_Object o = lua_getparam (1);
+ if (o == NULL)
+ { lua_error ("too few arguments to function `rad'"); return; }
+ if (!lua_isnumber(o))
+ { lua_error ("incorrect arguments to function `rad'"); return; }
+ d = lua_getnumber(o);
+ lua_pushnumber (d/180.*PI);
+}
+
/*
** Open math library
*/
@@ -274,4 +298,6 @@ void mathlib_open (void)
lua_register ("log", math_log);
lua_register ("log10", math_log10);
lua_register ("exp", math_exp);
+ lua_register ("deg", math_deg);
+ lua_register ("rad", math_rad);
}