utilities.hpp

00001 // This file is part of the imaging2 class library.
00002 //
00003 // University of Innsbruck, Infmath Imaging, 2009.
00004 // http://infmath.uibk.ac.at
00005 //
00006 // All rights reserved.
00007 
00008 
00009 #ifndef CORE_UTILITIES
00010 #define CORE_UTILITIES
00011 
00012 
00013 #include <iostream>
00014 #include <sstream>
00015 #include <math.h>
00016 #include <core/imaging2.hpp>
00017 
00018 #include <boost/lexical_cast.hpp>
00019 
00020 
00021 namespace imaging
00022 {
00027   const double PI = 3.1415926;
00028   
00033   const double SQUARE_ROOT_2 = 1.414213562373095049;
00034   
00039   const double SQUARE_ROOT_3 = 1.73205080757;
00040 
00045   template <class num_t>
00046   inline num_t max(const num_t a, const num_t b) { return a > b ? a : b; }
00047 
00052   template <class num_t>
00053   inline num_t min(const num_t a, const num_t b) { return a < b ? a : b; }
00054 
00059   template <class num_t>
00060   inline num_t square(num_t a) { return a * a; }
00061 
00066   template <class num_t>
00067   inline num_t power(num_t a, size_t b)
00068   { 
00069     if(b == 0)
00070       return num_t(1.0);
00071     else
00072       return power(a, b - 1) * a;
00073   }
00074   
00079   template <class num_t>
00080   inline num_t abs(num_t a)
00081   {
00082     return a < 0 ? -a : a;
00083   }
00084   
00085   template <>
00086   inline float abs(float a)
00087   {
00088     return fabs(a);
00089   }
00090   
00091   template <>
00092   inline double abs(double a)
00093   {
00094     return fabs(a);
00095   }
00096   
00097   
00102   template <class num_t>
00103   inline num_t sign(num_t a)
00104   {
00105     if(a == num_t(0))
00106       return num_t(0);
00107       
00108     return a < 0 ? num_t(-1) : num_t(1);
00109   }
00110   
00111   
00116   float_t delta(size_t base, size_t t);
00117   
00118   
00123   float_t clockwise_difference(float_t angle_1, float_t angle_2);
00124   
00125   
00130   float_t counter_clockwise_difference(float_t angle_1, float_t angle_2);
00131 }
00132 
00133 #endif

Generated on Tue Feb 10 10:01:29 2009 for imaging2 by  doxygen 1.5.5