Source code: exptree/operators/sine.java
1 /* Evolvo - Image Generator
2 * Copyright (C) 2000 Andrew Molloy
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /*
20 * @(#)sine.java 0.1 08/19/2000
21 */
22 package exptree.operators;
23
24 import java.io.*;
25 import exptree.*;
26
27 /**
28 * Caluclates the sine of an expressionTree's value.
29 *
30 * This particular application expects all inputs and outputs on the expressionTree
31 * to be bound to [-1.0,1.0], so this function is not actually natural sine.
32 *
33 * @version 1.1 08/19/2000
34 * @author Andy Molloy
35 */
36 public class sine implements operatorInterface, Serializable
37 {
38
39 /** Perform the operation. */
40 public double evaluate(expressionTree params[])
41 {
42 return( Math.sin(params[0].evaluate()) );
43 }
44
45 /** Returns the operator's name. */
46 public String getName()
47 {
48 return "sin";
49 }
50
51 /** Performs any initialization the operator requires. */
52 public void init() {}
53
54 /** Returns the number of parameters expected by the operator. */
55 public int getNumberOfParameters() { return 1; }
56 }