diff options
-rw-r--r-- | arith.c | 6 | ||||
-rw-r--r-- | eval.c | 1 | ||||
-rw-r--r-- | lib.h | 1 | ||||
-rw-r--r-- | txr.1 | 6 |
4 files changed, 12 insertions, 2 deletions
@@ -1431,6 +1431,12 @@ val atang(val num) return flo(atan(c_flo(to_float(lit("atan"), num)))); } +val atang2(val y, val x) +{ + return flo(atan2(c_flo(to_float(lit("atan2"), y)), + c_flo(to_float(lit("atan2"), x)))); +} + val loga(val num) { return flo(log(c_flo(to_float(lit("log"), num)))); @@ -2361,6 +2361,7 @@ void eval_init(void) reg_fun(intern(lit("asin"), user_package), func_n1(asine)); reg_fun(intern(lit("acos"), user_package), func_n1(acosi)); reg_fun(intern(lit("atan"), user_package), func_n1(atang)); + reg_fun(intern(lit("atan2"), user_package), func_n2(atang2)); reg_fun(intern(lit("log"), user_package), func_n1(loga)); reg_fun(intern(lit("exp"), user_package), func_n1(expo)); reg_fun(intern(lit("sqrt"), user_package), func_n1(sqroot)); @@ -479,6 +479,7 @@ val tang(val); val asine(val); val acosi(val); val atang(val); +val atang2(val, val); val loga(val); val expo(val); val logand(val, val); @@ -8895,7 +8895,7 @@ If <number> an integer, it is simply returned. If the argument is a float, then the value returned is a float. For instance (floor 1.1) returns 1.0 rather than 1. -.SS Functions sin, cos, tan, asin, acos, atan +.SS Functions sin, cos, tan, asin, acos, atan, atan2 .TP Syntax: @@ -8904,6 +8904,7 @@ Syntax: (cos <radians>) (tan <radians>) (atan <slope>) + (atan2 <y> <x>) (asin <num>) (acos <num>) @@ -8915,7 +8916,8 @@ return a float result. The sin, cos and tan functions compute the sine and cosine and tangent of the <radians> argument which represents an angle expressed in radians. The atan, acos and asin are their respective inverse functions. The <num> argument to asin and acos must be in the -range -1.0 to 1.0. +range -1.0 to 1.0. The atan2 function converts the rectilinear coordinates +<x> and <y> to an angle in polar coordinates in the range [0, 2pi). .SS Functions log, exp |