1 /*****************************************************************************/
2 // Copyright 2006-2019 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE:  Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8 
9 #ifndef __dng_spline__
10 #define __dng_spline__
11 
12 /*****************************************************************************/
13 
14 #include "dng_1d_function.h"
15 #include "dng_memory.h"
16 
17 /*****************************************************************************/
18 
EvaluateSplineSegment(real64 x,real64 x0,real64 y0,real64 s0,real64 x1,real64 y1,real64 s1)19 inline real64 EvaluateSplineSegment (real64 x,
20 								     real64 x0,
21 								     real64 y0,
22 								     real64 s0,
23 								     real64 x1,
24 								     real64 y1,
25 								     real64 s1)
26 	{
27 
28 	real64 A = x1 - x0;
29 
30 	real64 B = (x - x0) / A;
31 
32 	real64 C = (x1 - x) / A;
33 
34 	real64 D = ((y0 * (2.0 - C + B) + (s0 * A * B)) * (C * C)) +
35 			   ((y1 * (2.0 - B + C) - (s1 * A * C)) * (B * B));
36 
37 	return D;
38 
39 	}
40 
41 /*****************************************************************************/
42 
43 class dng_spline_solver: public dng_1d_function
44 	{
45 
46 	protected:
47 
48 		dng_std_vector<real64> X;
49 		dng_std_vector<real64> Y;
50 
51 		dng_std_vector<real64> S;
52 
53 	public:
54 
55 		dng_spline_solver ();
56 
57 		virtual ~dng_spline_solver ();
58 
59 		void Reset ();
60 
61 		void Add (real64 x, real64 y);
62 
63 		virtual void Solve ();
64 
65 		virtual bool IsIdentity () const;
66 
67 		virtual real64 Evaluate (real64 x) const;
68 
69 	};
70 
71 /*****************************************************************************/
72 
73 #endif
74 
75 /*****************************************************************************/
76