From: <jom...@us...> - 2014-09-26 12:05:06
|
Revision: 1811 http://sourceforge.net/p/jason/svn/1811 Author: jomifred Date: 2014-09-26 12:05:02 +0000 (Fri, 26 Sep 2014) Log Message: ----------- add trigonometric functions Added Paths: ----------- trunk/src/jason/functions/acos.java trunk/src/jason/functions/asin.java trunk/src/jason/functions/atan.java trunk/src/jason/functions/cos.java trunk/src/jason/functions/sin.java trunk/src/jason/functions/tan.java Added: trunk/src/jason/functions/acos.java =================================================================== --- trunk/src/jason/functions/acos.java (rev 0) +++ trunk/src/jason/functions/acos.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.acos(N)</code></b>: encapsulates java Math.acos(N), + returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. + + @author Jomi +*/ +public class acos extends DefaultArithFunction { + + public String getName() { + return "math.acos"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.acos(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/asin.java =================================================================== --- trunk/src/jason/functions/asin.java (rev 0) +++ trunk/src/jason/functions/asin.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.asin(N)</code></b>: encapsulates java Math.asin(N), + returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. + + @author Jomi +*/ +public class asin extends DefaultArithFunction { + + public String getName() { + return "math.asin"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.asin(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/atan.java =================================================================== --- trunk/src/jason/functions/atan.java (rev 0) +++ trunk/src/jason/functions/atan.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.atan(N)</code></b>: encapsulates java Math.atan(N), + returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2. + + @author Jomi +*/ +public class atan extends DefaultArithFunction { + + public String getName() { + return "math.atan"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.atan(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/cos.java =================================================================== --- trunk/src/jason/functions/cos.java (rev 0) +++ trunk/src/jason/functions/cos.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.cos(N)</code></b>: encapsulates java Math.cos(N), + returns the trigonometric cosine of an angle. + + @author Jomi +*/ +public class cos extends DefaultArithFunction { + + public String getName() { + return "math.cos"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.cos(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/sin.java =================================================================== --- trunk/src/jason/functions/sin.java (rev 0) +++ trunk/src/jason/functions/sin.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.sin(N)</code></b>: encapsulates java Math.sin(N), + returns the trigonometric sine of an angle. + + @author Jomi +*/ +public class sin extends DefaultArithFunction { + + public String getName() { + return "math.sin"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.sin(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/tan.java =================================================================== --- trunk/src/jason/functions/tan.java (rev 0) +++ trunk/src/jason/functions/tan.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.tan(N)</code></b>: encapsulates java Math.tan(N), + returns the trigonometric tangent of an angle. + + @author Jomi +*/ +public class tan extends DefaultArithFunction { + + public String getName() { + return "math.tan"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.tan(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |