mirror of
https://github.com/apple/pkl.git
synced 2026-07-07 21:45:22 +02:00
Add math.atan2 (#819)
This commit is contained in:
@@ -299,6 +299,28 @@ public final class MathNodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract static class atan2 extends ExternalMethod2Node {
|
||||||
|
@Specialization
|
||||||
|
protected double eval(VmTyped self, long x, long y) {
|
||||||
|
return StrictMath.atan2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Specialization
|
||||||
|
protected double eval(VmTyped self, long x, double y) {
|
||||||
|
return StrictMath.atan2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Specialization
|
||||||
|
protected double eval(VmTyped self, double x, double y) {
|
||||||
|
return StrictMath.atan2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Specialization
|
||||||
|
protected double eval(VmTyped self, double x, long y) {
|
||||||
|
return StrictMath.atan2(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract static class gcd extends ExternalMethod2Node {
|
public abstract static class gcd extends ExternalMethod2Node {
|
||||||
@TruffleBoundary
|
@TruffleBoundary
|
||||||
@Specialization
|
@Specialization
|
||||||
|
|||||||
@@ -130,6 +130,13 @@ examples {
|
|||||||
math.atan(math.tan(-2.34))
|
math.atan(math.tan(-2.34))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
["atan2"] {
|
||||||
|
math.atan2(4, -3)
|
||||||
|
math.atan2(4.5, -3.5)
|
||||||
|
math.atan2(4.5, -3)
|
||||||
|
math.atan2(4, 3.5)
|
||||||
|
}
|
||||||
|
|
||||||
["gcd"] {
|
["gcd"] {
|
||||||
math.gcd(0, 0)
|
math.gcd(0, 0)
|
||||||
math.gcd(4, 6)
|
math.gcd(4, 6)
|
||||||
@@ -189,3 +196,10 @@ examples {
|
|||||||
math.min(Infinity, -Infinity)
|
math.min(Infinity, -Infinity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
facts {
|
||||||
|
["atan2"] {
|
||||||
|
math.atan2(1, 0) == math.pi / 2
|
||||||
|
math.atan2(0, -1) == math.pi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
facts {
|
||||||
|
["atan2"] {
|
||||||
|
true
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
examples {
|
examples {
|
||||||
["minInt"] {
|
["minInt"] {
|
||||||
-9223372036854775808
|
-9223372036854775808
|
||||||
@@ -109,6 +115,12 @@ examples {
|
|||||||
1.1415926535897931
|
1.1415926535897931
|
||||||
0.8015926535897934
|
0.8015926535897934
|
||||||
}
|
}
|
||||||
|
["atan2"] {
|
||||||
|
2.214297435588181
|
||||||
|
2.2318394956455836
|
||||||
|
2.1587989303424644
|
||||||
|
0.851966327173272
|
||||||
|
}
|
||||||
["gcd"] {
|
["gcd"] {
|
||||||
0
|
0
|
||||||
2
|
2
|
||||||
|
|||||||
@@ -145,6 +145,12 @@ external function acos(x: Number): Float
|
|||||||
/// [1]: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
/// [1]: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
|
||||||
external function atan(x: Number): Float
|
external function atan(x: Number): Float
|
||||||
|
|
||||||
|
/// Returns the [2-argument arctangent][1] of [x] and [y].
|
||||||
|
///
|
||||||
|
/// [1]: https://en.wikipedia.org/wiki/Atan2
|
||||||
|
@Since { version = "0.28.0" }
|
||||||
|
external function atan2(x: Number, y: Number): Float
|
||||||
|
|
||||||
/// Returns the [greatest common divisor][1] of [x] and [y].
|
/// Returns the [greatest common divisor][1] of [x] and [y].
|
||||||
///
|
///
|
||||||
/// [1]: https://en.wikipedia.org/wiki/Greatest_common_divisor
|
/// [1]: https://en.wikipedia.org/wiki/Greatest_common_divisor
|
||||||
|
|||||||
Reference in New Issue
Block a user