From 36111276c6f0f1e9f83fa48519714eb6f7bd5a6c Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 5 Nov 2022 20:36:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=A2math.Atan2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins.h | 2 +- src/builtins/arithd.c | 7 +++++++ src/builtins/arithm.c | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/builtins.h b/src/builtins.h index 6725298a..5d79619f 100644 --- a/src/builtins.h +++ b/src/builtins.h @@ -17,7 +17,7 @@ /*internal.c*/M(itype,"•internal.Type") M(elType,"•internal.ElType") M(refc,"•internal.Refc") M(isPure,"•internal.IsPure") A(info,"•internal.Info") M(heapDump,"•internal.HeapDump") \ /*internal.c*/M(squeeze,"•internal.Squeeze") M(deepSqueeze,"•internal.DeepSqueeze") D(eequal,"•internal.EEqual") A(internalTemp,"•internal.Temp") \ /*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare") \ -/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan") +/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan") D(atan2,"•math.Atan2") #define FOR_PM1(A,M,D) \ /*md1.c*/A(tbl,"⌜") A(each,"¨") A(fold,"´") A(scan,"`") A(const,"˙") A(swap,"˜") A(cell,"˘") A(insert,"˝") \ diff --git a/src/builtins/arithd.c b/src/builtins/arithd.c index a0ac1be6..211d9955 100644 --- a/src/builtins/arithd.c +++ b/src/builtins/arithd.c @@ -16,6 +16,7 @@ B mul_c2(B, B, B); B root_c2(B, B, B); B and_c2(B, B, B); B stile_c2(B, B, B); B or_c2 (B, B, B); B log_c2(B, B, B); B floor_c2(B, B, B); +B atan2_c2(B, B, B); typedef void (*AndBytesFn)(u8*, u8*, u64, u64); @@ -359,4 +360,10 @@ AR_F_SCALAR("|", stile, pfmod(x.f, w.f)) AR_F_SCALAR("⋆⁼",log , log(x.f)/log(w.f)) #undef AR_F_SCALAR +B atan2_c2(B t, B w, B x) { + if (isNum(w) && isNum(x)) return m_f64(atan2(x.f, w.f)); + P2(atan2) + thrM("•math.Atan2: Unexpected argument types"); +} + #undef P2 diff --git a/src/builtins/arithm.c b/src/builtins/arithm.c index ddee07a6..15bea57b 100644 --- a/src/builtins/arithm.c +++ b/src/builtins/arithm.c @@ -107,8 +107,8 @@ static B mathNS; B getMathNS() { if (mathNS.u == 0) { #define F(X) inc(bi_##X), - Body* d = m_nnsDesc("sin","cos","tan","asin","acos","atan"); - mathNS = m_nns(d, F(sin)F(cos)F(tan)F(asin)F(acos)F(atan)); + Body* d = m_nnsDesc("sin","cos","tan","asin","acos","atan","atan2"); + mathNS = m_nns(d, F(sin)F(cos)F(tan)F(asin)F(acos)F(atan)F(atan2)); #undef F gc_add(mathNS); }