[an error occurred while processing this directive]
Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

lens_calibrate/HermiteSpline.h

Go to the documentation of this file.
00001 /* HermiteSpline.h  16 Feb 2008 TKS
00002 
00003   Hermite Spline Interpolation Routines 
00004   lifted & adapted from John Burkardt's collection at
00005   http://people.scs.fsu.edu/~burkardt/cpp_src/spline/spline.html
00006   NOTE FORTRAN style 1-origin array indexing
00007 
00008 */
00009 /*  Copyrignt (C) 2008, 2009 Thomas K Sharpless
00010  *  tksharpless@gmail.com
00011  *
00012  *  This program is free software; you can redistribute it and/or
00013  *  modify it under the terms of the GNU General Public
00014  *  License as published by the Free Software Foundation; either
00015  *  version 2 of the License, or (at your option) any later version.
00016  *
00017  *  This software is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  *  General Public License for more details.
00021  *
00022  *  You should have received a copy of the GNU General Public
00023  *  License along with this software; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 #ifndef _HERMITESPLINE_H
00029 #define _HERMITESPLINE_H
00030 
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 /* tabulate coefficients for Hermite spline interpolation of y(t)
00037    tdata[ndata], ydata[ndata] are tabulated y{t} values
00038    ypdata[ndata] are its 1st derivatives at same t's (how you set
00039      these determines the curviness of the spline)
00040    Note t values must be monotonic but intervals can vary
00041    Returns pointer to a new array c[4*ndata] of coefficients
00042    Note c[4*ndata] is to be allocated by caller
00043 */
00044 double * spline_hermite_set ( double c[], int ndata, double tdata[], double ydata[], double ypdata[] );
00045 
00046 /* compute hermite spline interpolation
00047    tdata[ndata] = tabulated t values; c[4*ndata] = coefficients
00048    tval = interpolation point
00049    sval -> returned interpolated y value
00050    spval -> returned derivative at that point (0: no derivative computed)
00051   returns 0: bad input or 1: sucess
00052 */
00053 int spline_hermite_val ( int ndata, double tdata[], double c[],
00054                           double tval, double * sval, double * spval );
00055 
00056 /* set tangents (1st divided differences) for a tabulated function
00057      whose tabulation interval need not be uniform.
00058      these can serve as the derivatives for setting up a spline.
00059      
00060    Input: ndata, tdata[ndata], ydata[ndata] as above.
00061           ypdata[ndata] -- place for the result
00062   
00063    returns 0 if tdata[] is not monotonic or ndata < 2 or the 
00064              range of t or y is < 1e-11, else
00065                    1 if ydata[] is monotonic, else
00066               -1 if ydata[] is not monotonic
00067 
00068    If y is monotonic, the tangents are adjusted to ensure that all
00069      interpolated values will be monotonic as well.
00070 
00071 */
00072 int spline_tangents_set( int ndata, double tdata[], double ydata[], double ypdata[] );
00073 
00074 /*  Find the interval (if any) in t[n] that contains x
00075     t[] must be monotonic ascending or descending
00076         returns i if x == t[i]
00077   returns index (0:n-2) of the left end of the interval, or
00078           -1 if x is out of range
00079                   -2 if t is not monotonic
00080   method: linear interpolation search
00081 */
00082 int findInterval( int n, double t[], double x );
00083 
00084 
00085 #ifdef __cplusplus
00086 }
00087 #endif
00088 
00089 #endif  //ndef _HERMITESPLINE_H
00090 
00091 

Generated on Mon Sep 20 01:01:27 2010 for Hugintrunk by doxygen 1.3.9.1