contrib/brl/bbas/bsta/bsta_kent.h
Go to the documentation of this file.
00001 // This is brl/bbas/bsta/bsta_kent.h
00002 #ifndef bsta_kent_h_
00003 #define bsta_kent_h_
00004 //:
00005 // \file
00006 // \brief  Kent distribution function implementation
00007 // \author Gamze Tunali (gtunali@brown.edu)
00008 // \date   March 5, 2010
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   (none yet)
00013 // \endverbatim
00014 
00015 #include "bsta_distribution.h"
00016 #include <vnl/vnl_vector_fixed.h>
00017 #include <vnl/vnl_matrix_fixed.h>
00018 #if 0
00019 #include <vgl/vgl_plane_3d.h>
00020 #endif
00021 #include <vsl/vsl_binary_io.h>
00022 #include <vcl_vector.h>
00023 #include <vcl_iostream.h>
00024 
00025 template <class T>
00026 class bsta_kent // : public bsta_distribution<T,1>
00027 {
00028  public:
00029   //: default constructor
00030   bsta_kent()
00031    : kappa_(0), beta_(0), gamma1_(vnl_vector_fixed<T,3>(0,0,0)),
00032      gamma2_(vnl_vector_fixed<T,3>(0,0,0)), gamma3_(vnl_vector_fixed<T,3>(0,0,0)) {}
00033 
00034   bsta_kent(T kappa, T beta, vnl_vector_fixed<T,3> const& gamma1,
00035             vnl_vector_fixed<T,3> const& gamma2, vnl_vector_fixed<T,3> const& gamma3)
00036    : kappa_(kappa), beta_(beta), gamma1_(gamma1), gamma2_(gamma2), gamma3_(gamma3) {}
00037 
00038   int version() const { return 1; }
00039 
00040 #if 0
00041   //: constructs kent distr. from a set of planes
00042   bsta_kent(vcl_vector<vgl_plane_3d<T> > const& planes);
00043 #endif
00044 
00045   //: construct from a 3x3 matrix
00046   bsta_kent(vnl_matrix_fixed<T,3,3> const& m);
00047 
00048   ~bsta_kent() {}
00049 
00050   T kappa() const { return kappa_; }
00051   T beta() const { return beta_; }
00052   vnl_vector_fixed<T,3> minor_axis() const { return gamma1_; }
00053   vnl_vector_fixed<T,3> major_axis() const { return gamma2_; }
00054   vnl_vector_fixed<T,3> mean_direction() const { return gamma3_; }
00055 
00056   //: true if unimodal, false if bimodal
00057   bool unimodal() const { return kappa_/beta_ >= T(2); }
00058 
00059   //: pre:
00060   T prob_density(vnl_vector_fixed<T,3> const& x);
00061 
00062   vnl_vector_fixed<T,3> mean() const { return gamma1_; /* vcl_pow(kappa_,beta_); ??? */ }
00063 
00064  private:
00065   T kappa_;  // concentration or spread of the distribution (SHOULD BE > 0)
00066   T beta_;   // ellipticity of the contours of equal probability (ovalness parameter)
00067   vnl_vector_fixed<T,3> gamma1_;
00068   vnl_vector_fixed<T,3> gamma2_;
00069   vnl_vector_fixed<T,3> gamma3_;
00070 
00071   //: normalizing constant method
00072   T normalizing_const(T kappa=0, T beta=0);
00073 };
00074 
00075 template <class T>
00076 void vsl_b_write(vsl_b_ostream & os, bsta_kent<T> const& b);
00077 
00078 template <class T>
00079 void vsl_b_write(vsl_b_ostream & os, bsta_kent<T> const* &b);
00080 
00081 template <class T>
00082 void vsl_b_read(vsl_b_istream & is, bsta_kent<T> &b);
00083 
00084 template <class T>
00085 void vsl_b_read(vsl_b_istream & is, bsta_kent<T> *&b);
00086 
00087 template <class T>
00088 vcl_ostream& operator<< (vcl_ostream& os, bsta_kent<T> & b);
00089 
00090 #endif