contrib/brl/bbas/bsta/bsta_von_mises.h
Go to the documentation of this file.
00001 // This is brl/bbas/bsta/bsta_von_mises.h
00002 #ifndef bsta_von_mises_h_
00003 #define bsta_von_mises_h_
00004 //:
00005 // \file
00006 // \brief A distribution over unit vectors (orientation on a d-sphere)
00007 // \author Joseph L. Mundy
00008 // \date July 6, 2009
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   (none yet)
00013 // \endverbatim
00014 //
00015 // do not remove the following text
00016 // Approved for public release, distribution unlimited (DISTAR Case 14389)
00017 //
00018 
00019 #include "bsta_distribution.h"
00020 #include <vcl_vector.h>
00021 #include <vcl_iostream.h>
00022 
00023 //: A Von_Mises distribution
00024 template <class T, unsigned n>
00025 class bsta_von_mises : public bsta_distribution<T,n>
00026 {
00027  public:
00028   typedef typename bsta_distribution<T,n>::vector_type vector_type;
00029   typedef typename bsta_distribution<T,n>::math_type math_type;
00030   typedef typename bsta_distribution<T,n>::field_type field_type;
00031   enum { data_dimension = n };
00032   bsta_von_mises(): mean_(vector_type(T(0))), kappa_(T(1)) {}
00033   bsta_von_mises(vector_type const& mean, T kappa): mean_(mean), kappa_(kappa) {}
00034   virtual ~bsta_von_mises() {}
00035   //: The mean vector
00036   const vector_type& mean() const {return mean_;}
00037   void set_mean(const vector_type& mean) {mean_ = mean;}
00038 
00039   //: the concentration parameter (kappa)
00040   T kappa() const {return kappa_;}
00041   void set_kappa(T kappa) {kappa_=kappa;}
00042 
00043   //: The probability density at a given unit vector
00044   T prob_density(vector_type const& v) const{vcl_cerr << "not implemented\n"; return 0;}
00045 
00046   //:Probability of an angular range of vectors about v, which defines a cone.
00047   T probability(vector_type const& v,const T theta_max) const {vcl_cerr << "not implemented\n"; return 0;}
00048 
00049  protected:
00050   //: The mean vector
00051   vector_type mean_;
00052   //: The concentration parameter (kappa)
00053   T kappa_;
00054 };
00055 
00056 
00057 #if VCL_CAN_DO_PARTIAL_SPECIALIZATION
00058 template <class T>
00059 class bsta_von_mises<T,3>
00060 {
00061  public:
00062   typedef typename bsta_distribution<T,3>::math_type math_type;
00063   typedef typename bsta_distribution<T,3>::vector_type vector_type;
00064   typedef typename bsta_distribution<T,3>::field_type field_type;
00065   enum { data_dimension = 3 };
00066   bsta_von_mises(): mean_(vector_type(T(0))), kappa_(T(1)) {mean_[2]=T(1);}
00067   bsta_von_mises(vector_type const& mean, T kappa): mean_(mean), kappa_(kappa) {}
00068   virtual ~bsta_von_mises() {}
00069   //: The mean vector
00070   const vector_type& mean() const {return mean_;}
00071   void set_mean(const vector_type& mean) { mean_ = mean; }
00072 
00073   //: the concentration parameter (kappa)
00074   T kappa() const {return kappa_;}
00075   void set_kappa(T kappa) {kappa_=kappa;}
00076   //: The probability density at a given unit vector
00077   T prob_density(vector_type const& v) const;
00078 
00079   //:Probability of an angular range of vectors about v, which defines a cone.
00080   // theta_max is in radians
00081   T probability(vector_type const& v,const T theta_max) const;
00082 
00083  protected:
00084   //: The mean vector
00085   vector_type mean_;
00086   //: The concentration parameter (kappa)
00087   T kappa_;
00088 };
00089 
00090 
00091 template <class T>
00092 class bsta_von_mises<T,2>
00093 {
00094  public:
00095   typedef typename bsta_distribution<T,2>::math_type math_type;
00096   typedef typename bsta_distribution<T,2>::vector_type vector_type;
00097   typedef typename bsta_distribution<T,2>::field_type field_type;
00098   enum { data_dimension = 2 };
00099   bsta_von_mises(): mean_(vector_type(T(0))), kappa_(T(1)) { mean_[1]=T(1); }
00100   bsta_von_mises(vector_type const& mean, T kappa): mean_(mean), kappa_(kappa) {}
00101   virtual ~bsta_von_mises() {}
00102   //: The mean vector
00103   const vector_type& mean() const {return mean_;}
00104   void set_mean(const vector_type& mean) {mean_ = mean;}
00105 
00106   //: the concentration parameter (kappa)
00107   T kappa() const {return kappa_;}
00108   void set_kappa(T kappa) {kappa_=kappa;}
00109 
00110   //: The probability density at a given unit vector
00111   T prob_density(vector_type const& v) const;
00112 
00113   //:Probability of an angular range of vectors about v, which defines a cone.
00114   T probability(vector_type const& /*v*/,const T /*theta_max*/) const {vcl_cerr << "not implemented\n"; return 0;}
00115 
00116  protected:
00117   //: The mean vector
00118   vector_type mean_;
00119   //: The concentration parameter (kappa)
00120   T kappa_;
00121 };
00122 
00123 #endif //VCL_CAN_DO_PARTIAL_SPECIALIZATION
00124 
00125 template <class T , unsigned n>
00126 inline vcl_ostream& operator<< (vcl_ostream& os,
00127                                 bsta_von_mises<T, n> const& vm)
00128 {
00129   os << "von_mises:mean(" << vm.mean() << ")\n"
00130      << "von_mises:kappa(" << vm.kappa() << ")\n";
00131   return os;
00132 }
00133 #endif // bsta_von_mises_h_