Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

math::spline(3pm) [debian man page]

Spline(3pm)						User Contributed Perl Documentation					       Spline(3pm)

NAME
Math::Spline - Cubic Spline Interpolation of data SYNOPSIS
require Math::Spline; $spline=new Math::Spline(@x,@y) $y_interp=$spline->evaluate($x); use Math::Spline qw(spline linsearch binsearch); use Math::Derivative qw(Derivative2); @y2=Derivative2(@x,@y); $index=binsearch(@x,$x); $index=linsearch(@x,$x,$index); $y_interp=spline(@x,@y,@y2,$index,$x); DESCRIPTION
This package provides cubic spline interpolation of numeric data. The data is passed as references to two arrays containing the x and y ordinates. It may be used as an exporter of the numerical functions or, more easily as a class module. The Math::Spline class constructor new takes references to the arrays of x and y ordinates of the data. An interpolation is performed using the evaluate method, which, when given an x ordinate returns the interpolate y ordinate at that value. The spline function takes as arguments references to the x and y ordinate array, a reference to the 2nd derivatives (calculated using De- rivative2, the low index of the interval in which to interpolate and the x ordinate in that interval. Returned is the interpolated y ordi- nate. Two functions are provided to look up the appropriate index in the array of x data. For random calls binsearch can be used - give a reference to the x ordinates and the x loopup value it returns the low index of the interval in the data in which the value lies. Where the lookups are strictly in ascending sequence (e.g. if interpolating to produce a higher resolution data set to draw a curve) the linsearch function may more efficiently be used. It performs like binsearch, but requires a third argument being the previous index value, which is incremented if necessary. NOTE
requires Math::Derivative module EXAMPLE
require Math::Spline; my @x=(1,3,8,10); my @y=(1,2,3,4); $spline=new Math::Spline(@x,@y); print $spline->evaluate(5)." "; produces the output 2.44 HISTORY
$Log: Spline.pm,v $ Revision 1.1 1995/12/26 17:28:17 willijar Initial revision BUGS
Bug reports or constructive comments are welcome. AUTHOR
John A.R. Williams <J.A.R.Williams@aston.ac.uk> SEE ALSO
"Numerical Recipies: The Art of Scientific Computing" W.H. Press, B.P. Flannery, S.A. Teukolsky, W.T. Vetterling. Cambridge University Press. ISBN 0 521 30811 9. perl v5.8.8 2007-08-17 Spline(3pm)

Check Out this Related Man Page

tkspline(3tk)				   Tk Spline - An additional smoothing method for canvas items				     tkspline(3tk)

__________________________________________________________________________________________________________________________________________________

NAME
spline, - additional smoothing method for canvas items. SYNOPSIS
package require Tkspline ... .c create line ... -smooth spline ... .c create polygon ... -smooth spline ... _________________________________________________________________ INTRODUCTION
The new option value: -smooth spline provides an additional smoothing method to line and polygon canvas items. Spline smoothing will revert to the builtin smoothing method unless the number of points is 3n+1, where n is the number of spline segments. (Normally in polygons this means 3n points because the last point of the spline is understood to be the same as the first in order to close the polygon). In line and polygon items, the curves generated with the standard -smooth true option have the following properties: - the curve is always tangential to a straight line between consecutive points. - the curve is only guaranteed to intersect the first and last points of lines. - the curve is not guaranteed to intersect any points of polygons. With -smooth spline (and the right number of coordinates) the curves generated have the following different properties: - the curve is guaranteed to intersect the first point, and every third point after that. - each segment of the curve shares endpoints with the adjacent segments, but is otherwise independent of them. - the curve is guaranteed to be tangential to a line between n and n+1 at point n, and also to a line between n+2 and n+3 at point n+3. - the curve is not guaranteed to be smooth at the junctions between segments unless the shared point and the points either side of it are on a straight line. These alternative properties are useful to some path planning algorithms. CREDITS
The underlying Bezier code is in John Ousterhout's original canvas widget, this extension just provides an alternate interface to it. The hooks into the canvas are provided by Jan Nijtmans in his "dash" patch. KEYWORDS
spline, line, polygon, bezier, canvas, widget AUTHOR
John Ellson, ellson@graphviz.org Tk 8.0 tkspline(3tk)
Man Page