contrib/brl/bbas/bugl/bugl_gaussian_point_3d.txx
Go to the documentation of this file.
00001 #ifndef bugl_gaussian_point_3d_txx_
00002 #define bugl_gaussian_point_3d_txx_
00003 
00004 #include "bugl_gaussian_point_3d.h"
00005 #include <vnl/vnl_inverse.h>
00006 #include <vnl/vnl_det.h>
00007 #include <vnl/vnl_math.h>
00008 #include <vnl/vnl_vector_fixed.h>
00009 
00010 template<class T>
00011 void bugl_gaussian_point_3d<T>::set_covariant_matrix(vnl_matrix_fixed<T, 3, 3> const& s)
00012 {
00013   sigma_ = s;
00014   sigma_inv_ = vnl_inverse(s);
00015   det_ = vnl_det(s);
00016 }
00017 
00018 template<class T>
00019 T bugl_gaussian_point_3d<T>::prob_at(vgl_point_3d<T> const& p) const
00020 {
00021  if (!this->exists_)
00022   return 0;
00023   vnl_vector_fixed<T, 3> d(p.x() - this->x(), p.y() - this->y(), p.z() - this->z());
00024 
00025   const double pi = vnl_math::pi;
00026   return vcl_exp(-0.5*(dot_product(d, sigma_inv_*d)))/vcl_sqrt(8*pi)/pi/det_;
00027 }
00028 
00029 #if 0
00030 template<class T>
00031 bugl_gaussian_point_3d<T>& bugl_gaussian_point_3d<T>::operator=(bugl_gaussian_point_3d<T> const& p)
00032 {
00033   vnl_matrix_fixed<T, 3, 3> t = p.get_covariant_matrix();
00034   set_covariant_matrix(t);
00035   set_point(p);
00036   return *this;
00037 }
00038 #endif // 0
00039 
00040 //----------------------------------------------------------------------------
00041 #undef BUGL_GAUSSIAN_POINT_3D_INSTANTIATE
00042 #define BUGL_GAUSSIAN_POINT_3D_INSTANTIATE(T) \
00043 template class bugl_gaussian_point_3d<T >
00044 
00045 #endif // bugl_gaussian_point_3d_txx_