Class EDU.emporia.mathtools.SplineFunction
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.emporia.mathtools.SplineFunction

Object
   |
   +----MathFunction
           |
           +----EDU.emporia.mathtools.SplineFunction

public class SplineFunction
extends MathFunction
A class that constructs a cubic spline passing through a specified set of points. The slope at each point can be specified or generated automatically.

Version:
1.0
Author:
Joe Yanik
Since:
6/6/2001

Variable Index

 o autoSlope
An Vector of boolean values that keeps track of whether the slope at each point should stay fixed or should be automatically adjusted as new points are added.
 o points
The Vector that will contain the points used to define the function.
 o slopes
The Vector that will be used to define the slopes that will be used to define the curve.

Constructor Index

 o EDU.emporia.mathtools.SplineFunction()
 o EDU.emporia.mathtools.SplineFunction(Point2D.Double[])

Method Index

 o addPoint(Point2D.Double)
Adds the indicated point to the list of points used to construct the function.
 o addPoint(Point2D.Double, double)
Adds the indicated points to the list of points and specifies the slope of the curve at that point.
 o addPoint(double, double, double)
Adds a point with the given x and y coordinates and specifies the slope at that point.
 o addPoint(double, double)
Adds the point with the specified x and y coordinate.
 o addPoints(Point2D.Double[])
Adds the indicate array of points to the ones that are being used to define the function.
 o functionValue(double)
Overrides the functionValue method of the MathFunction class.
 o getPoints()
Gets the array of points that are being used to define the function.
 o getSlopes()
Gets the array of slopes that are being used to define the curve.
 o removeAllPoints()
Removes all points from the list of points that are used to define the function.
 o removePoint(Point2D.Double)
Removes the indicated point from the list of points that are being used to define the function
 o removePoint(double, double)
Removes the point with the indicated x and y coordinate from the list of points that are used to define the functoin
 o removePoint()
Removes the point with the largest x coordinate
 o setSlope(Point2D.Double, double)
Sets the slope of the curve at the given point

Variables

 o autoSlope
protected java.util.Vector autoSlope
An Vector of boolean values that keeps track of whether the slope at each point should stay fixed or should be automatically adjusted as new points are added.

 o points
protected java.util.Vector points
The Vector that will contain the points used to define the function. They will always be listed in increasing order of x-value.

 o slopes
protected java.util.Vector slopes
The Vector that will be used to define the slopes that will be used to define the curve. The slope at a particular index will correspond to the point at that same index in the points Vector.

Constructors

 o SplineFunction
public SplineFunction()
 o SplineFunction
public SplineFunction(EDU.emporia.mathtools.Point2D.Double[] p)

Methods

 o addPoint
public void addPoint(EDU.emporia.mathtools.Point2D.Double p) throws IllegalPointError
Adds the indicated point to the list of points used to construct the function. The graph will then pass through the specified point. It will throw an exception if there is already a point with that x-coordinate. The slope at the point will generated automatically.

Parameters:
p - The point to be added.
Throws: IllegalPointError
 o addPoint
public void addPoint(EDU.emporia.mathtools.Point2D.Double p,
                     double slope) throws IllegalPointError
Adds the indicated points to the list of points and specifies the slope of the curve at that point. The graph of the function will then pass through the added point with the slope specified.

Parameters:
p - The point to be added.
slope - The slope of the curve at that point.
Throws: IllegalPointError
This will be thrown when there is already a point with the indicated x-value.
 o addPoint
public void addPoint(double x,
                     double y,
                     double slope) throws IllegalPointError
Adds a point with the given x and y coordinates and specifies the slope at that point.

Parameters:
x - The x coordinate of the point to be added.
y - The y coordinate of the point to be added.
slope - The slope of the curve at the added point.
Throws: IllegalPointError
Thrown when there is already a point with the given x coordinate.
 o addPoint
public void addPoint(double x,
                     double y) throws IllegalPointError
Adds the point with the specified x and y coordinate. It throws an IllegalPointError if there is already a point with the given x-coordinate. The slope is generated automatically.

Parameters:
x - The x-coordinate of the point to be added
y - The y-coordinate of the point to be added.
Throws: IllegalPointError
This will be thrown is there is an attempt to add a point with the same x coordinate as one that is already being used.
 o addPoints
public void addPoints(EDU.emporia.mathtools.Point2D.Double[] p) throws IllegalPointError
Adds the indicate array of points to the ones that are being used to define the function. If any of the points contains an x-value that is already being used it will throw and IllegalPointError. The slopes will be generated automatically.

Parameters:
p - The array of points to be added.
Throws: IllegalPointError
Thrown is there is a duplicate x-value.
 o functionValue
public double functionValue(double u)
Overrides the functionValue method of the MathFunction class. This method returns the value of the function at the specified x-coordinate

Parameters:
u - The x-coordinate
Returns:
f(x)
Overrides:
functionValue in class MathFunction
 o getPoints
public EDU.emporia.mathtools.Point2D.Double[] getPoints()
Gets the array of points that are being used to define the function.

Returns:
The array of points
 o getSlopes
public double[] getSlopes()
Gets the array of slopes that are being used to define the curve.

Returns:
The array of slopes.
 o removeAllPoints
public void removeAllPoints()
Removes all points from the list of points that are used to define the function.

 o removePoint
public void removePoint(EDU.emporia.mathtools.Point2D.Double p)
Removes the indicated point from the list of points that are being used to define the function

Parameters:
p - The point to be removed.
 o removePoint
public void removePoint(double x,
                        double y)
Removes the point with the indicated x and y coordinate from the list of points that are used to define the functoin

Parameters:
x - The x-coordinate of the point to be removed.
y - The y-coordinate of the point to be removed.
 o removePoint
public void removePoint()
Removes the point with the largest x coordinate

 o setSlope
public void setSlope(EDU.emporia.mathtools.Point2D.Double p,
                     double m) throws IllegalPointError
Sets the slope of the curve at the given point

Parameters:
p - The point at which the slope is to be set.
m - The slope at the indicated point.
Throws: IllegalPointError

All Packages  Class Hierarchy  This Package  Previous  Next  Index