IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 4, 2023, 12:09:57 PM (3 years ago)
Author:
eugene
Message:

merge changes from trunk : new spline implementation, remove excess verbosity

Location:
branches/eam_branches/ipp-20220316/psLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/psLib

  • branches/eam_branches/ipp-20220316/psLib/src/math/psSpline.h

    r23486 r42368  
    55 * and evaluate splines.
    66 *
    7  * @author GLG, MHPCC
     7 * @author GLG (MHPCC)
     8 * reworked by EAM (IfA)
    89 *
    910 * @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
     
    2728#include "psPolynomial.h"
    2829
    29 #define PS_LEFT_SPLINE_DERIV 0.0
    30 #define PS_RIGHT_SPLINE_DERIV 0.0
    31 
    32 /** One-Dimensional Spline */
     30/** One-Dimensional Spline
     31    This structure represents a 1D cubic spline.  Note the option for
     32    equally-spaced knots allows a quick selection of the correct spline
     33    segment.  The values (xMin, xMax, xDel) are stored for ease of access.
     34 */
    3335typedef struct
    3436{
    35     unsigned int n;                    ///< The number of spline pieces
    36     psPolynomial1D **spline;           ///< An array of n pointers to the spline polynomials
    37     psVector *knots;                   ///< The boundaries between each spline piece.  Size is n+1.
    38     psF32 *p_psDeriv2;                 ///< For cubic splines, the second derivative at each domain point.  Size is n+1.
     37    unsigned int n;    ///< The number of knots
     38    psF32 *xKnots; ///< x-coordinate of the knots
     39    psF32 *yKnots; ///< y-coordinate of the knots
     40    psF32 *d2yKnots; ///< 2nd derivative of y at the knots
     41    bool equalSpacing; // if knots are equally spaced, the seqment choice can be optimized
     42    psF32 xMin; // for equally-spaced knots, the value at the lower bound (xKnots[0])
     43    psF32 xMax; // for equally-spaced knots, the value at the upper bound (xKnots[n])
     44    psF32 xDel; // for equally-spaced knots, the spacing (xKnots[n] - xKnots[0])/n
    3945}
    4046psSpline1D;
    4147
    42 /** Allocates a psSpline1D structure
    43  *
    44  *  Allocator for psSpline1D.
     48/** Allocator for psSpline1D.
    4549 *
    4650 *  @return psSpline1D*    new 1-D spline struct
    4751 */
    4852psSpline1D *psSpline1DAlloc(void) PS_ATTR_MALLOC;
     53
     54/** Create an empty 1D spline **/
     55psSpline1D *psSpline1DCreate(
     56    int nKnots);                        ///< number of knots
    4957
    5058/** Evaluates 1-D spline polynomials at a specific coordinate.
     
    5361 */
    5462float psSpline1DEval(
    55     const psSpline1D *spline,          ///< Coefficients for spline polynomials
     63    const psSpline1D *spline,          ///< spline pointer
     64    float x                            ///< location at which to evaluate
     65);
     66
     67/** Evaluates 1-D spline polynomials at a specific coordinate.
     68 *
     69 *  @return float    result of spline polynomials evaluated at given location
     70 */
     71float psSpline1DEval_Segment(
     72    const psSpline1D *spline,          ///< spline pointer
     73    int n,                             // choice of segment
    5674    float x                            ///< location at which to evaluate
    5775);
     
    7189 *  generates the linear splines which satisfy those data points.
    7290 *
     91 *  XXX EAM: add option to generate / select a subset of knots from the data
     92 *
    7393 *  @return psSpline1D*:  the calculated one-dimensional splines
    7494 */
    75 psSpline1D *psVectorFitSpline1D(
     95psSpline1D *psSpline1DFitVector(
    7696    const psVector* x,                 ///< Ordinates (or NULL to just use the indices)
    77     const psVector* y                  ///< Coordinates
     97    const psVector* y,                  ///< Coordinates.
     98    psF32 dyLower,                      ///< 1st derivative at lower bound
     99    psF32 dyUpper                       ///< 1st derivative at upper bound
    78100);
    79101
     
    87109    psPtr ptr                          ///< the pointer whose type to check
    88110);
     111
     112// check for equal spacing and set internal boolean if true
     113bool psSpline1DisEqualSpacing (psSpline1D *spline);
     114
     115// convert the cubic spline elements to a simply ordinary polynomial for segment n
     116psPolynomial1D *psSpline1DToPoly (psSpline1D *spline, int n);
    89117
    90118/*****************************************************************************
Note: See TracChangeset for help on using the changeset viewer.