FastCubicIpol.hpp

00001 
00002 //
00003 // $Id: FastCubicIpol.hpp,v 1.1 2006/07/07 14:10:53 werner Exp $
00004 //
00005 // $Log: FastCubicIpol.hpp,v $
00006 // Revision 1.1  2006/07/07 14:10:53  werner
00007 // Intermediate state: multidimensional interpolation with on-demand
00008 // fractional loading appears to work, but still problem with vectorfield
00009 // interpolation.
00010 //
00011 // Revision 1.7  2004/08/12 16:08:45  werner
00012 // Various improvements for implementing the tangential space
00013 //
00014 // Revision 1.6  2004/07/09 20:15:26  werner
00015 // Added local alignment capability when interpolating vector fields and
00016 // option to compute the interpolated derivative.
00017 //
00018 // Revision 1.5  2004/07/04 17:24:03  werner
00019 // Recursive multidimensional Interpolation interface implemented.
00020 //
00021 // Revision 1.4  2004/06/18 23:29:46  werner
00022 // Intermediate version that supports the recursive interpolation scheme.
00023 // Need to beautify the interface, fix some indexing bug, and make it to
00024 // work with the ViewPtr.
00025 //
00026 // Revision 1.3  2004/06/15 23:31:00  werner
00027 // Support for interpolation of quaternions within the interpolation interfaces.
00028 //
00029 // Revision 1.2  2004/06/15 22:45:31  werner
00030 // Enhanced the fixed array member functions.
00031 // Using better name for interpolation template parameters.
00032 //
00033 // Revision 1.1  2004/06/14 22:42:00  werner
00034 // Moved interpolation files from light++ to VecAl and Multindex from Fiber to VecAl.
00035 //
00036 //
00038 #ifndef __IPOL_FASTCUBICIPOL_PP
00039 #define __IPOL_FASTCUBICIPOL_HPP "Created 11.06.2004 22:28:21 by bzfbenge"
00040 
00041 #include "IpolDelimiter.hpp"
00042 
00043 namespace Fiber
00044 {
00045 
00056 template <class T>
00057 class   FastCubicIpol
00058 {
00059 public:
00060 
00061         template <class Storage1D, class Limiter>
00062 static  T interpolate(const Storage1D&Data, double t, index_t size, const Limiter&L)
00063         {
00064                 // TODO: Check for Samplings.size() < 2 !
00065                 assert(size > 2);
00066 
00067                 if (t<0     ) return Data[0];
00068                 if (t>=size ) return Data[size-1];
00069 
00070         index_t i = index_t(t); 
00071                 t = t - floor(t); 
00072 
00073         //      3 x^2 - 2 x^3
00074                 t = t*t*(3-2*t);
00075 
00076                 return Data[i] * (1-t) + Data[i+1] * (t);
00077         }
00078 
00079         template <class Storage1D>
00080 static  T derivative(const Storage1D&Data, double t, index_t size)
00081         {
00082         index_t i = index_t(t); 
00083                 t = t - floor(t); 
00084 
00085                 //      3 x^2 - 2 x^3
00086                 //      6 x   - 6 x^2
00087         double  x = 6*t*(1-t);
00088 
00089                 return (Data[i+1] - Data[i] )*x;
00090         }
00091 };
00092 
00093 } /* namespace VecAl */ 
00094 
00095 #endif /* __IPOL_FASTCUBICIPOL_HPP */