| 1 | /*****************************************************************************/ |
| 2 | // Copyright 2006-2007 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 | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_spline.h#1 $ */ |
| 10 | /* $DateTime: 2012/05/30 13:28:51 $ */ |
| 11 | /* $Change: 832332 $ */ |
| 12 | /* $Author: tknoll $ */ |
| 13 | |
| 14 | /*****************************************************************************/ |
| 15 | |
| 16 | #ifndef __dng_spline__ |
| 17 | #define __dng_spline__ |
| 18 | |
| 19 | /*****************************************************************************/ |
| 20 | |
| 21 | #include "dng_1d_function.h" |
| 22 | #include "dng_memory.h" |
| 23 | |
| 24 | #include <vector> |
| 25 | |
| 26 | /*****************************************************************************/ |
| 27 | |
| 28 | inline real64 EvaluateSplineSegment (real64 x, |
| 29 | real64 x0, |
| 30 | real64 y0, |
| 31 | real64 s0, |
| 32 | real64 x1, |
| 33 | real64 y1, |
| 34 | real64 s1) |
| 35 | { |
| 36 | |
| 37 | real64 A = x1 - x0; |
| 38 | |
| 39 | real64 B = (x - x0) / A; |
| 40 | |
| 41 | real64 C = (x1 - x) / A; |
| 42 | |
| 43 | real64 D = ((y0 * (2.0 - C + B) + (s0 * A * B)) * (C * C)) + |
| 44 | ((y1 * (2.0 - B + C) - (s1 * A * C)) * (B * B)); |
| 45 | |
| 46 | return D; |
| 47 | |
| 48 | } |
| 49 | |
| 50 | /*****************************************************************************/ |
| 51 | |
| 52 | class dng_spline_solver: public dng_1d_function |
| 53 | { |
| 54 | |
| 55 | protected: |
| 56 | |
| 57 | dng_std_vector<real64> X; |
| 58 | dng_std_vector<real64> Y; |
| 59 | |
| 60 | dng_std_vector<real64> S; |
| 61 | |
| 62 | public: |
| 63 | |
| 64 | dng_spline_solver (); |
| 65 | |
| 66 | virtual ~dng_spline_solver (); |
| 67 | |
| 68 | void Reset (); |
| 69 | |
| 70 | void Add (real64 x, real64 y); |
| 71 | |
| 72 | virtual void Solve (); |
| 73 | |
| 74 | virtual bool IsIdentity () const; |
| 75 | |
| 76 | virtual real64 Evaluate (real64 x) const; |
| 77 | |
| 78 | }; |
| 79 | |
| 80 | /*****************************************************************************/ |
| 81 | |
| 82 | #endif |
| 83 | |
| 84 | /*****************************************************************************/ |
| 85 | |