summaryrefslogtreecommitdiff
path: root/source/dng_spline.h
blob: cc790205c0d897b8dbcd5249f6f28ebb7f95c856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*****************************************************************************/
// Copyright 2006-2007 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/

/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_spline.h#1 $ */ 
/* $DateTime: 2012/05/30 13:28:51 $ */
/* $Change: 832332 $ */
/* $Author: tknoll $ */

/*****************************************************************************/

#ifndef __dng_spline__
#define __dng_spline__

/*****************************************************************************/

#include "dng_1d_function.h"
#include "dng_memory.h"

#include <vector>

/*****************************************************************************/

inline real64 EvaluateSplineSegment (real64 x,
								     real64 x0,
								     real64 y0,
								     real64 s0,
								     real64 x1,
								     real64 y1,
								     real64 s1)
	{
	
	real64 A = x1 - x0;

	real64 B = (x - x0) / A;

	real64 C = (x1 - x) / A;

	real64 D = ((y0 * (2.0 - C + B) + (s0 * A * B)) * (C * C)) +
			   ((y1 * (2.0 - B + C) - (s1 * A * C)) * (B * B));
			   
	return D;
	
	}

/*****************************************************************************/

class dng_spline_solver: public dng_1d_function
	{
	
	protected:
	
		dng_std_vector<real64> X;
		dng_std_vector<real64> Y;
		
		dng_std_vector<real64> S;
		
	public:
	
		dng_spline_solver ();
		
		virtual ~dng_spline_solver ();
			
		void Reset ();

		void Add (real64 x, real64 y);

		virtual void Solve ();

		virtual bool IsIdentity () const;

		virtual real64 Evaluate (real64 x) const;

	};

/*****************************************************************************/

#endif
	
/*****************************************************************************/