Building Parsers with Java

sjm.examples.sling
Class Cos

java.lang.Object
  |
  +--sjm.examples.sling.SlingFunction
        |
        +--sjm.examples.sling.Cos

public class Cos
extends SlingFunction

This class wraps a cos function around another source function.

The cos function is the x component of a stone's location at an angle given in radians.


Fields inherited from class sjm.examples.sling.SlingFunction
source
 
Constructor Summary
Cos()
          Constructs cos(t).
Cos(SlingFunction source)
          Constructs a function object that wraps a cos function around the given source function.
 
Method Summary
 Point f(double t)
          Returns, essentially, cos(source.f(t)).
 java.lang.String toString()
          Returns a string representation of this function.
 
Methods inherited from class sjm.examples.sling.SlingFunction
eval, extrema, fresh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cos

public Cos()
Constructs cos(t).

Cos

public Cos(SlingFunction source)
Constructs a function object that wraps a cos function around the given source function.
Method Detail

f

public Point f(double t)
Returns, essentially, cos(source.f(t)).
Overrides:
f in class SlingFunction
Parameters:
t - a number that represents how far along a plot is, and thus tells which point to return
Returns:
a new point: (t, cos(source.f(t).y))
See Also:
Abs, Abs.f(double)

toString

public java.lang.String toString()
Returns a string representation of this function.
Overrides:
toString in class java.lang.Object

by Steve Metsker