com.codetaco.math.impl.function.FuncAtan Maven / Gradle / Ivy
package com.codetaco.math.impl.function;
import com.codetaco.math.impl.Function;
import com.codetaco.math.impl.ValueStack;
import com.codetaco.math.impl.token.TokVariable;
import java.text.ParseException;
/**
*
* FuncAtan class.
*
*
* @author Chris DeGreef [email protected]
* @since 1.3.9
*/
public class FuncAtan extends Function {
/**
*
* Constructor for FuncAtan.
*
*/
public FuncAtan() {
super();
}
/**
*
* Constructor for FuncAtan.
*
*
* @param var a {@link com.codetaco.math.impl.token.TokVariable} object.
*/
public FuncAtan(final TokVariable var) {
super(var);
}
/**
* {@inheritDoc}
*/
@Override
public void resolve(final ValueStack values) throws Exception {
if (values.size() < 1) {
throw new Exception("missing operands for " + toString());
}
try {
values.push(new Double(Math.atan(values.popDouble()) * 180 / Math.PI));
} catch (final ParseException e) {
e.fillInStackTrace();
throw new Exception(toString() + "; " + e.getMessage(), e);
}
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "function(acotan)";
}
}