00001 /* 00002 * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software 00003 * 00004 * The Software has been developped within the Siames Project. 00005 * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights 00006 * 00007 * The Software has been registered with the Agence pour la Protection des 00008 * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200 00009 * 00010 * This file may be distributed under the terms of the Q Public License 00011 * version 1.0 as defined by Trolltech AS of Norway and appearing in the file 00012 * LICENSE.QPL included in the packaging of this file. 00013 * 00014 * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 00015 * for the software may use this file in accordance with that specific license 00016 * 00017 */ 00018 #ifndef PsNumericTypeIMPLEMENTATION 00019 #define PsNumericTypeIMPLEMENTATION 00020 #include <PsNumericTypeT.h> 00021 #include <math.h> 00022 #include <PsNumericPolator.h> 00023 00024 //------------------------------------------------------------------------ 00025 //*********************************************************************** 00026 //** interpolation PsPolatorNT::Linear a partir d'un indice de la file et de la date 00027 //** de son arrive pour compute une pente 00028 //** calcul --> 00029 // t[indice-1]-t[indice] 00030 // pente = --------------------- 00031 // Temps[Indice-1] - Temps[Indice] 00032 // 00033 // on cherche a recuperer une valeur a la date tValeur 00034 // 00035 // l 'ordonne a l'origine : t[indice-1] - pente*Temps[indice-1] 00036 // 00037 // -----> valeur = pente*tValeur + ordonnee a l'origine 00038 // 00039 // 00040 // tIndice-1 < t < tIndice 00041 // 00042 //*********************************************************************** 00043 00044 // v0 valeur a la date t0 00045 // v1 valeur precedente v1 = file[t0-deltaTemps] 00046 00047 00048 double PsNumericType::linearInterpolate( 00049 const long t, 00050 const long t1, 00051 const double v1, 00052 const long t0, 00053 const double v0 00054 ) 00055 { 00056 #ifdef _DEBUGPOLATION 00057 cerr<<"linearInterpolate("<<t<<" "<<t1<<" "<<v1<<" "<<t0<<" "<<v0<<") = "<<endl; 00058 #endif 00059 long d0 = t1 - t0 ; 00060 assert ( d0 != 0) ; 00061 #ifdef _DEBUGPOLATION 00062 cerr<< ( v1 * (t - t0 ) + v0 * ( t1 - t )) / d0 <<endl; 00063 #endif 00064 return ( v1 * (t - t0 ) + v0 * ( t1 - t )) / d0 ; 00065 } 00066 //------------------------------------------------------------------------ 00067 00068 00069 double PsNumericType::quadraticInterpolate(const long t, 00070 const long t2, 00071 const double v2, 00072 const long t1, 00073 const double v1, 00074 const long t0, 00075 const double v0 00076 ) 00077 { 00078 return v0 + linearInterpolate(t-t0,t2-t0,v2-v0,t1-t0,v1-v0) ; 00079 } 00080 00081 00082 double PsNumericType::cubicInterpolate(const long t, 00083 const long t3, 00084 const double v3, 00085 const long t2, 00086 const double v2, 00087 const long t1, 00088 const double v1, 00089 const long t0, 00090 const double v0 ) 00091 { 00092 return v0 + quadraticInterpolate(t - t0, 00093 t3 - t0, 00094 v3 - v0, 00095 t2 - t0, 00096 v2 - v0, 00097 t1 - t0, 00098 v1 - v0); 00099 } 00100 //------------------------------------------------------------------------ 00101 00102 double PsNumericType::linearExtrapolate(const long t, 00103 const long t1, 00104 const double v1, 00105 const long t0, 00106 const double v0 00107 ) 00108 { 00109 #ifdef _DEBUGPOLATION 00110 cerr<<"linearExtrapolate ("<<t<<","<<t1<<","<<v1<<","<<t0<<","<<v0<<") = "; 00111 #endif 00112 long d0 = (t1 - t0); 00113 //assert ( false ) ; 00114 assert(t1 != -1) ; 00115 assert(t != -1) ; 00116 assert ( t != t1 ) ; 00117 double resul = ( (t - t1) * (v1 - v0) )/ d0 + v1; 00118 #ifdef _DEBUGPOLATION 00119 cerr<<resul<<endl; 00120 #endif 00121 return ( (t - t1) * (v1 - v0) )/ d0 + v1 ; 00122 } 00123 //------------------------------------------------------------------------ 00124 00125 00126 double PsNumericType::quadraticExtrapolate(const long t3, 00127 const long t2, 00128 const double v2, 00129 const long t1, 00130 const double v1, 00131 const long t0, 00132 const double v0) 00133 { 00134 #ifdef _DEBUGPOLATION 00135 cerr<<"quadraticExtrapolate ("<<t3<<","<<t2<<","<<v2<<","<<t1<<","<<v1<<","<<t0<<","<<v0<<") = "; 00136 #endif 00137 //on utilise linearExtrapolate pour compute l'accroissement en t2 et t3 00138 double deltaValeur = linearExtrapolate(t3-t0, 00139 t2-t0, 00140 v2-v0, 00141 t1-t0, 00142 v1-v0); 00143 #ifdef _DEBUGPOLATION 00144 cerr<<v2+deltaValeur<<endl; 00145 #endif 00146 return v0+deltaValeur ; 00147 } 00148 00149 //------------------------------------------------------------------------ 00150 00151 double PsNumericType::cubicExtrapolate(const long t4, 00152 const long t3, 00153 const double v3, 00154 const long t2, 00155 const double v2, 00156 const long t1, 00157 const double v1, 00158 const long t0, 00159 const double v0 00160 ) 00161 { 00162 double deltaValeur = quadraticExtrapolate(t4 - t0, 00163 t3 - t0, 00164 v3 - v0, 00165 t2 - t0, 00166 v2 - v0, 00167 t1 - t0, 00168 v1 - v0); 00169 return v0 + deltaValeur ; 00170 } 00171 //------------------------------------------------------------------------ 00172 00173 #endif 00174 00175 00176 00177 00178 00179 00180
| Documentation generated on Mon Nov 25 15:25:01 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |