From adde8a18a5affd01cff261ce540264cf28e8e59c Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 16 Oct 2016 16:38:49 -0400 Subject: Added polar coordinates to RPN --- complexfunctions.html | 2 +- js/complex.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/complexfunctions.html b/complexfunctions.html index d22920c..6b6f9ed 100644 --- a/complexfunctions.html +++ b/complexfunctions.html @@ -102,12 +102,12 @@ Graph complex functions (C->C) sin Sine cos Cosine tan Tangent + r, theta Polar coordinates ln Natural logarithm ($\log_e x$) log Logarithm ($\log_a b$) sinh Hyperbolic sine cosh Hyperbolic cosine tanh Hyperbolic tangent - diff --git a/js/complex.js b/js/complex.js index 04241f9..f0d9644 100644 --- a/js/complex.js +++ b/js/complex.js @@ -282,6 +282,12 @@ complex.rpn = function (s) case "pi": stack.push(complex.PI); break; + case "r": + stack.push(complex.reToC(complex.abs(stack.pop()))); + break; + case "theta": + stack.push(complex.reToC(complex.theta(stack.pop()))); + break; default: if (token[token.length-1] == "i") { -- cgit v1.2.3