From efe76a6fdc4c4a9245aa4ef632deec22eed6529a Mon Sep 17 00:00:00 2001 From: Arthur Drobot Date: Wed, 9 Aug 2017 15:08:54 -0700 Subject: [PATCH] Add arccos. --- .../nwapw/abacus/plugin/StandardPlugin.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java index cad9445..78d457b 100755 --- a/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/StandardPlugin.java @@ -453,7 +453,6 @@ public class StandardPlugin extends Plugin { /** * The arcsin function (return type in radians). - * @param manager */ public final Function functionArcsin = new Function() { @Override @@ -485,6 +484,22 @@ public class StandardPlugin extends Plugin { } }; + /** + * The arccos function. + */ + public final Function functionArccos = new Function() { + @Override + protected boolean matchesParams(NumberInterface[] params) { + return params.length == 1 && FUNCTION_ABS.apply(params[0]).compareTo(fromInt(params[0].getClass(), 1)) <= 0; + } + + @Override + protected NumberInterface applyInternal(NumberInterface[] params) { + return piFor(params[0].getClass()).divide(fromInt(params[0].getClass(), 2)) + .subtract(functionArcsin.apply(params)); + } + }; + public StandardPlugin(PluginManager manager) { super(manager); } @@ -603,6 +618,7 @@ public class StandardPlugin extends Plugin { registerFunction("csc", functionCsc); registerFunction("cot", functionCot); registerFunction("arcsin", functionArcsin); + registerFunction("arccos", functionArccos); } @Override