sjm.examples.sling
Class Cartesian
java.lang.Object
|
+--sjm.examples.sling.SlingFunction
|
+--sjm.examples.sling.Cartesian
- public class Cartesian
- extends SlingFunction
This class combines the y component of each of two source
functions to form a new two-dimensional function. This
allows functions which are normally one-dimensional to
recombine into a two-dimensional function.
For example, both sin and cos are
normally one-dimensional functions, returning a single
number for any given value. The classes Sin
and Cos store their results in the y dimension
of a function, augmenting any particular point with t as
the x value. Objects of the Cartesian class
ignore the x component of each source function. The y
component of the first source function becomes the x
component of the Cartesian function, and the y
component of the second function becomes the y component of
the Cartesian function.
Consider the following program, which plots a circle:
theta = 2*pi*t;
x = cos(theta);
y = sin(theta);
plot cartesian(x, y);
The design principles at play in this package augment the x
and y functions above, so that they are effectively
cartesian(t, cos(theta)) and
cartesian(t, sin(theta)). The program
recombines the y components of these functions into a new
cartesian with an x value of cos(theta)
and a y value of sin(theta).
|
Constructor Summary |
Cartesian()
Constructs cartesian(t, t). |
Cartesian(SlingFunction sX,
SlingFunction sY)
Constructs a function object that combines the y components
of the two sources into the x and y values of a new
function. |
|
Method Summary |
Point |
f(double t)
Combine the y components of the sources into a new point. |
java.lang.String |
toString()
Returns a string representation of this function. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Cartesian
public Cartesian()
- Constructs
cartesian(t, t).
Cartesian
public Cartesian(SlingFunction sX,
SlingFunction sY)
- Constructs a function object that combines the y components
of the two sources into the x and y values of a new
function.
f
public Point f(double t)
- Combine the y components of the sources into a new point.
- 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:
(sx.f(t).y, sy.f(t).y)
toString
public java.lang.String toString()
- Returns a string representation of this function.
- Overrides:
- toString in class java.lang.Object