All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.obdobion.algebrain.function.FuncDegreesToRads Maven / Gradle / Ivy

The newest version!
package com.obdobion.algebrain.function;

import java.text.ParseException;

import com.obdobion.algebrain.Function;
import com.obdobion.algebrain.ValueStack;
import com.obdobion.algebrain.token.TokVariable;

/**
 * 

* FuncDegreesToRads class. *

* * @author Chris DeGreef [email protected] * @since 1.3.9 */ public class FuncDegreesToRads extends Function { /** *

* Constructor for FuncDegreesToRads. *

*/ public FuncDegreesToRads() { super(); } /** *

* Constructor for FuncDegreesToRads. *

* * @param var a {@link com.obdobion.algebrain.token.TokVariable} object. */ public FuncDegreesToRads(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 { final double degrees = values.popDouble(); final double rads = degrees * (Math.PI / 180); values.push(new Double(rads)); } catch (final ParseException e) { e.fillInStackTrace(); throw new Exception(toString() + "; " + e.getMessage(), e); } } /** {@inheritDoc} */ @Override public String toString() { return "function(rad)"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy