Class PiecewiseFunction
Defined in: Piecewise.js.
Constructor Attributes | Constructor Name and Description |
---|---|
PiecewiseFunction(functs, ranges)
Object representing mathematical piecewise functions
|
Field Attributes | Field Name and Description |
---|---|
<static> <constant> |
PiecewiseFunction.serializeName
A static constant to help with de/serialization
|
Method Attributes | Method Name and Description |
---|---|
createFirstDegSpline(points)
Given a list of points generates a piece-wise spline function of the first degree.
|
|
createSecondDegSpline(points, zzero)
Given a list of points generates a piece-wise spline function of the second degree.
|
|
createThirdDegSpline(points)
Creates a Natural Cubic Spline given a series of points
|
|
<static> |
PiecewiseFunction.fromWebWorker(that)
Reconstitutes a PiecewiseFunction object and its data members after passed to web worker
|
{Point[]}
|
Generate points for SVG paths/curves
|
{Double}
|
resolve(value)
Applies the function on the value and returns the result
|
{string}
|
toString()
Creates a simple string representation of the piecewise function
|
{Object}
|
Prepares an Object ready to be passed to a web worker
|
Class Detail
PiecewiseFunction(functs, ranges)
Object representing mathematical piecewise functions
- Parameters:
- {Resolveable[]} functs
- An array of objects implementing the resolve method
- {Range[]} ranges
- An array of Range objects for each of the functs provided
Field Detail
<static> <constant>
PiecewiseFunction.serializeName
A static constant to help with de/serialization
Method Detail
{PiecewiseFunction}
createFirstDegSpline(points)
Given a list of points generates a piece-wise spline function of the first degree.
Roughly based on Page 374
test code:
var Q = [new Point(0,8),new Point(1,12),new Point(3,2),new Point(4,6),new Point(8,0)];
var Y = [new Point(0,8),new Point(1,6),new Point(3,5),new Point(4,3),new Point(6,2),new Point(8,0)];
ourGraph.points = Y;
var yspline = createFirstDegSpline(Y);
ourGraph.drawPoints();
ourGraph.drawFunction(yspline);
- Parameters:
- {Point[]} points
- An array of point objects sorted by x-value
- Returns:
- {PiecewiseFunction} The linear spline interpolation
{PiecewiseFunction}
createSecondDegSpline(points, zzero)
Given a list of points generates a piece-wise spline function of the second degree.
Roughly based on Page 380
test code:
var Q = [new Point(0,8),new Point(1,12),new Point(3,2),new Point(4,6),new Point(8,0)];
var Y = [new Point(0,8),new Point(1,6),new Point(3,5),new Point(4,3),new Point(6,2),new Point(8,0)];
var Z = [new Point(-1,2),new Point(0,1),new Point(0.5,0),new Point(1,1),new Point(2,2),new Point(5/2.0,3)];
ourGraph.points = Z;
var yspline = createSecondDegSpline(Z);
ourGraph.drawPoints();
ourGraph.drawFunction(yspline);
- Parameters:
- {Point[]} points
- An array of point objects sorted by x-value
- {Double} zzero
- 0 by default, otherwise the slope of the second derivative of the initial function
- Returns:
- {PiecewiseFunction} The quadratic spline interpolation
{PiecewiseFunction}
createThirdDegSpline(points)
Creates a Natural Cubic Spline given a series of points
Author: Sahil Diwan.
Author: Sahil Diwan.
- Parameters:
- {Point[]} points
- An array of points to interpolate
- Returns:
- {PiecewiseFunction} A piecewise function using polynomials of degree three IMPLEMENTED algorithm on page 392
<static>
PiecewiseFunction.fromWebWorker(that)
Reconstitutes a PiecewiseFunction object and its data members after passed to web worker
- Parameters:
- {Object} that
- A PiecewiseFunction strippd of its methods
{Point[]}
generateBezierPaths()
Generate points for SVG paths/curves
- Returns:
- {Point[]} Path control points in order
{Double}
resolve(value)
Applies the function on the value and returns the result
- Parameters:
- {Double} value
- The value to be used in the function
- Returns:
- {Double} The result
{string}
toString()
Creates a simple string representation of the piecewise function
- Returns:
- {string} The string representation
{Object}
toWebWorker()
Prepares an Object ready to be passed to a web worker
- Returns:
- {Object}