1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 15:30:09 -08:00

Add tan, sec, csc, cot in terms of what we currently have.

This commit is contained in:
Arthur Drobot 2017-08-03 10:30:42 -07:00
parent 8cf0c94947
commit 95845a1585

View File

@ -321,6 +321,54 @@ public class StandardPlugin extends Plugin {
}
};
public static final Function FUNCTION_TAN = new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 1;
}
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return FUNCTION_SIN.apply(params[0]).divide(FUNCTION_COS.apply(params[0]));
}
};
public static final Function FUNCTION_SEC = new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 1;
}
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return NaiveNumber.ONE.promoteTo(params[0].getClass()).divide(FUNCTION_COS.apply(params[0]));
}
};
public static final Function FUNCTION_CSC = new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 1;
}
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return NaiveNumber.ONE.promoteTo(params[0].getClass()).divide(FUNCTION_SIN.apply(params[0]));
}
};
public static final Function FUNCTION_COT = new Function() {
@Override
protected boolean matchesParams(NumberInterface[] params) {
return params.length == 1;
}
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return FUNCTION_COS.apply(params[0]).divide(FUNCTION_COS.apply(params[0]));
}
};
public StandardPlugin(PluginManager manager) {
super(manager);
}
@ -369,6 +417,10 @@ public class StandardPlugin extends Plugin {
registerFunction("sqrt", FUNCTION_SQRT);
registerFunction("sin", FUNCTION_SIN);
registerFunction("cos", FUNCTION_COS);
registerFunction("tan", FUNCTION_TAN);
registerFunction("sec", FUNCTION_SEC);
registerFunction("csc", FUNCTION_CSC);
registerFunction("cot", FUNCTION_COT);
}
@Override