File indexing completed on 2025-01-19 03:55:16

0001 /*****************************************************************************/
0002 // Copyright 2006-2019 Adobe Systems Incorporated
0003 // All Rights Reserved.
0004 //
0005 // NOTICE:  Adobe permits you to use, modify, and distribute this file in
0006 // accordance with the terms of the Adobe license agreement accompanying it.
0007 /*****************************************************************************/
0008 
0009 #ifndef __dng_spline__
0010 #define __dng_spline__
0011 
0012 /*****************************************************************************/
0013 
0014 #include "dng_1d_function.h"
0015 #include "dng_memory.h"
0016 
0017 /*****************************************************************************/
0018 
0019 inline real64 EvaluateSplineSegment (real64 x,
0020                                      real64 x0,
0021                                      real64 y0,
0022                                      real64 s0,
0023                                      real64 x1,
0024                                      real64 y1,
0025                                      real64 s1)
0026     {
0027 
0028     real64 A = x1 - x0;
0029 
0030     real64 B = (x - x0) / A;
0031 
0032     real64 C = (x1 - x) / A;
0033 
0034     real64 D = ((y0 * (2.0 - C + B) + (s0 * A * B)) * (C * C)) +
0035                ((y1 * (2.0 - B + C) - (s1 * A * C)) * (B * B));
0036 
0037     return D;
0038 
0039     }
0040 
0041 /*****************************************************************************/
0042 
0043 class dng_spline_solver: public dng_1d_function
0044     {
0045 
0046     protected:
0047 
0048         dng_std_vector<real64> X;
0049         dng_std_vector<real64> Y;
0050 
0051         dng_std_vector<real64> S;
0052 
0053     public:
0054 
0055         dng_spline_solver ();
0056 
0057         virtual ~dng_spline_solver ();
0058 
0059         void Reset ();
0060 
0061         void Add (real64 x, real64 y);
0062 
0063         virtual void Solve ();
0064 
0065         virtual bool IsIdentity () const;
0066 
0067         virtual real64 Evaluate (real64 x) const;
0068 
0069     };
0070 
0071 /*****************************************************************************/
0072 
0073 #endif
0074 
0075 /*****************************************************************************/