1
0
forked from Mirror/wren

Added Num.atan(x)

Maps to the C function atan2.
This commit is contained in:
Thorbjørn Lindeijer
2015-03-15 16:43:02 +01:00
parent 42dd7cdad4
commit 1099c75c77
2 changed files with 12 additions and 1 deletions

View File

@ -20,6 +20,11 @@ The arc sine of the number.
The arc tangent of the number.
### **atan**(x)
The arc tangent of the number when divided by `x`, using the signs of the two
numbers to determine the quadrant of the result.
### **ceil**
Rounds the number up to the nearest integer.

View File

@ -380,7 +380,7 @@ DEF_PRIMITIVE(class_supertype)
// Object has no superclass.
if (classObj->superclass == NULL) RETURN_NULL;
RETURN_OBJ(classObj->superclass);
}
@ -924,6 +924,11 @@ DEF_PRIMITIVE(num_atan)
RETURN_NUM(atan(AS_NUM(args[0])));
}
DEF_PRIMITIVE(num_atan2)
{
RETURN_NUM(atan2(AS_NUM(args[0]), AS_NUM(args[1])));
}
DEF_PRIMITIVE(num_ceil)
{
RETURN_NUM(ceil(AS_NUM(args[0])));
@ -1609,6 +1614,7 @@ void wrenInitializeCore(WrenVM* vm)
PRIMITIVE(vm->numClass, "acos", num_acos);
PRIMITIVE(vm->numClass, "asin", num_asin);
PRIMITIVE(vm->numClass, "atan", num_atan);
PRIMITIVE(vm->numClass, "atan(_)", num_atan2);
PRIMITIVE(vm->numClass, "ceil", num_ceil);
PRIMITIVE(vm->numClass, "cos", num_cos);
PRIMITIVE(vm->numClass, "floor", num_floor);