hypothesis2D.h

Go to the documentation of this file.
00001 #ifndef MMVL_HYPOTHESIS2D_HH
00002 #define MMVL_HYPOTHESIS2D_HH
00003 
00004 #ifndef NDEBUG
00005 #include <iostream>
00006 #endif
00007 
00008 #include "hypothesis.h"
00009 #include "dice.h"
00010 
00011 using namespace mimas;
00012 
00013 namespace mimas{
00014   namespace hf{
00015     
00023     class hypothesis2D: public hypothesis
00024       {
00025       public:
00026   float x;
00027   float y;
00029   static float sigmaSpan;
00030       
00032   // !! instead of using int(), use something to round to the nearest value 
00033   hypothesis2D drift(void) const
00034     {
00035       return hypothesis2D(int(x + Dice::gaussian_random() * sigmaSpan),
00036         int(y + Dice::gaussian_random() * sigmaSpan),
00037         weight);
00038     }
00039 
00040   //This is used by analyse_result_mean
00041   //when using this function make sure you are not dividing by 0 
00043   //bother about AnalyseResult won't have to implement it
00044   hypothesis2D mean(const hypothesis2D &h)
00045   {
00046     if(h.weight != 0)
00047       {
00048         float coord1 = (x * weight  + h.x * h.weight) /(weight + h.weight);
00049         float coord2 = (y * weight + h.y * h.weight) /(weight + h.weight);
00050 
00051         return hypothesis2D(coord1,
00052           coord2,
00053           weight + h.weight);
00054       }
00055     return *this;
00056   }
00057 
00058   float distance(const hypothesis2D &h)
00059   {
00060     return sqrt((h.x - x) * (h.x - x) + (h.y - y) * (h.y - y));
00061   }
00062 
00063   hypothesis2D(float x = 0, float y = 0, double weight = 0)
00064     :hypothesis(weight), x(x), y(y){}
00065       
00066       };
00067   }
00068 } 
00069 #endif

[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:17 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...