Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Math/MVTools.cpp

Go to the documentation of this file.
00001 /**
00002 * @file MVTools.cpp
00003 * Contains helper functions for Vector_n and Matrix_nxn
00004 *
00005 * @author <a href="mailto:stefanuhrig@gmx.net">Stefan Uhrig</a>
00006 */
00007 //------------------------------------------------------------------------------
00008 #include "MVTools.h"
00009 //------------------------------------------------------------------------------
00010 const char* MVException::getDescription() const
00011 {
00012   switch (type)
00013   {
00014   case DivByPosZero:
00015     return "Division by (positive) zero";
00016   case DivByNegZero:
00017     return "Division by (negative) zero";
00018   case PosInfValue:
00019     return "Infinite (positive) value";
00020   case NegInfValue:
00021     return "Infinite (negative) value";
00022   case DetNegative:
00023     return "Determinant negative";
00024   case DetCloseToZero:
00025     return "Determinant close to zero";
00026   default:
00027     return "Unknown";
00028   }
00029 }
00030 //------------------------------------------------------------------------------
00031 namespace MVTools
00032 {
00033 //------------------------------------------------------------------------------
00034 const double maxPosDouble = 1e150;
00035 const double maxNegDouble = -1e150;
00036 const double minPosDouble = 1e-150;
00037 const double minNegDouble = -1e-150;
00038 const double maxExpDouble = 345.38776;
00039 
00040 const float maxPosFloat = 1e18f;
00041 const float maxNegFloat = -1e18f;
00042 const float minPosFloat = 1e-18f;
00043 const float minNegFloat = -1e-18f;
00044 const float maxExpFloat = 41.4465f;
00045 
00046 const int maxPosInt = 2147483647;
00047 const int maxNegInt = -2147483647;
00048 const int minPosInt = 0;
00049 const int minNegInt = 0;
00050 //------------------------------------------------------------------------------
00051 bool isNearZero(double value)
00052 {
00053   if ((value > minNegDouble) &&
00054       (value < minPosDouble))
00055     return true;
00056   else
00057     return false;
00058 }
00059 //------------------------------------------------------------------------------
00060 bool isNearPosZero(double value)
00061 {
00062   if ((value >= 0.0) &&
00063       (value < minPosDouble))
00064     return true;
00065   else
00066     return false;
00067 }
00068 //------------------------------------------------------------------------------
00069 bool isNearNegZero(double value)
00070 {
00071   if ((value > minNegDouble) &&
00072       (value <= 0.0))
00073     return true;
00074   else
00075     return false;
00076 }
00077 //------------------------------------------------------------------------------
00078 bool isNearInf(double value)
00079 {
00080   if ((value > maxPosDouble) ||
00081       (value < maxNegDouble))
00082     return true;
00083   else
00084     return false;
00085 }
00086 //------------------------------------------------------------------------------
00087 bool isNearPosInf(double value)
00088 {
00089   if (value > maxPosDouble)
00090     return true;
00091   else
00092     return false;
00093 }
00094 //------------------------------------------------------------------------------
00095 bool isNearNegInf(double value)
00096 {
00097   if (value < maxNegDouble)
00098     return true;
00099   else
00100     return false;
00101 }
00102 //------------------------------------------------------------------------------
00103 double getMaxPosDouble()
00104 {
00105   return maxPosDouble;
00106 }
00107 //------------------------------------------------------------------------------
00108 double getMinPosDouble()
00109 {
00110   return minPosDouble;
00111 }
00112 //------------------------------------------------------------------------------
00113 double getMaxExpDouble()
00114 {
00115   return maxExpDouble;
00116 }
00117 //------------------------------------------------------------------------------
00118 bool isNearZero(float value)
00119 {
00120   if ((value > minNegFloat) &&
00121       (value < minPosFloat))
00122     return true;
00123   else
00124     return false;
00125 }
00126 //------------------------------------------------------------------------------
00127 bool isNearPosZero(float value)
00128 {
00129   if ((value >= 0.0) &&
00130       (value < minPosFloat))
00131     return true;
00132   else
00133     return false;
00134 }
00135 //------------------------------------------------------------------------------
00136 bool isNearNegZero(float value)
00137 {
00138   if ((value > minNegFloat) &&
00139       (value <= 0.0))
00140     return true;
00141   else
00142     return false;
00143 }
00144 //------------------------------------------------------------------------------
00145 bool isNearInf(float value)
00146 {
00147   if ((value > maxPosFloat) ||
00148       (value < maxNegFloat))
00149     return true;
00150   else
00151     return false;
00152 }
00153 //------------------------------------------------------------------------------
00154 bool isNearPosInf(float value)
00155 {
00156   if (value > maxPosFloat)
00157     return true;
00158   else
00159     return false;
00160 }
00161 //------------------------------------------------------------------------------
00162 bool isNearNegInf(float value)
00163 {
00164   if (value < maxNegFloat)
00165     return true;
00166   else
00167     return false;
00168 }
00169 //------------------------------------------------------------------------------
00170 float getMaxPosFloat()
00171 {
00172   return maxPosFloat;
00173 }
00174 //------------------------------------------------------------------------------
00175 float getMinPosFloat()
00176 {
00177   return minPosFloat;
00178 }
00179 //------------------------------------------------------------------------------
00180 float getMaxExpFloat()
00181 {
00182   return maxExpFloat;
00183 }
00184 //------------------------------------------------------------------------------
00185 bool isNearZero(int value)
00186 {
00187   if ((value > minNegInt) &&
00188       (value < minPosInt))
00189     return true;
00190   else
00191     return false;
00192 }
00193 //------------------------------------------------------------------------------
00194 bool isNearPosZero(int value)
00195 {
00196   if ((value >= 0.0) &&
00197       (value < minPosInt))
00198     return true;
00199   else
00200     return false;
00201 }
00202 //------------------------------------------------------------------------------
00203 bool isNearNegZero(int value)
00204 {
00205   if ((value > minNegInt) &&
00206       (value <= 0.0))
00207     return true;
00208   else
00209     return false;
00210 }
00211 //------------------------------------------------------------------------------
00212 bool isNearInf(int value)
00213 {
00214   if ((value > maxPosInt) ||
00215       (value < maxNegInt))
00216     return true;
00217   else
00218     return false;
00219 }
00220 //------------------------------------------------------------------------------
00221 bool isNearPosInf(int value)
00222 {
00223   if (value > maxPosInt)
00224     return true;
00225   else
00226     return false;
00227 }
00228 //------------------------------------------------------------------------------
00229 bool isNearNegInf(int value)
00230 {
00231   if (value < maxNegInt)
00232     return true;
00233   else
00234     return false;
00235 }
00236 //------------------------------------------------------------------------------
00237 int getMaxPosInt()
00238 {
00239   return maxPosInt;
00240 }
00241 //------------------------------------------------------------------------------
00242 int getMinPosInt()
00243 {
00244   return minPosInt;
00245 }
00246 //------------------------------------------------------------------------------
00247 };
00248 //------------------------------------------------------------------------------
00249 
00250 /*
00251  * Change log :
00252  * $Log: MVTools.cpp,v $
00253  * Revision 1.2  2004/06/16 17:57:00  nistico
00254  * Speed covariance submatrix dynamically calculated
00255  * based on distance from ball
00256  * More detailed identification of exception
00257  * Bug fixes
00258  *
00259  * Revision 1.1.1.1  2004/05/22 17:37:12  cvsadm
00260  * created new repository GT2004_WM
00261  *
00262  * Revision 1.2  2004/03/15 12:28:52  risler
00263  * change log added
00264  *
00265  *
00266  */

Generated on Thu Sep 23 19:57:39 2004 for GT2004 by doxygen 1.3.6