00001 #ifndef bugl_gaussian_point_2d_txx_ 00002 #define bugl_gaussian_point_2d_txx_ 00003 00004 #include "bugl_gaussian_point_2d.h" 00005 #include <vnl/vnl_inverse.h> 00006 #include <vnl/vnl_det.h> 00007 #include <vnl/vnl_vector_fixed.h> 00008 #include <vnl/vnl_math.h> 00009 00010 template<class T> 00011 void bugl_gaussian_point_2d<T>::set_covariant_matrix(vnl_matrix_fixed<T,2,2> 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_2d<T>::prob_at(vgl_point_2d<T> const& p) const 00020 { 00021 if (!this->exists_) 00022 return 0; 00023 vnl_vector_fixed<T, 2> v(p.x() - this->x(), p.y() - this->y()); 00024 return vcl_exp(-0.5*(dot_product(v, sigma_inv_*v)))/(2*vnl_math::pi*det_); 00025 } 00026 00027 //---------------------------------------------------------------------------- 00028 #undef BUGL_GAUSSIAN_POINT_2D_INSTANTIATE 00029 #define BUGL_GAUSSIAN_POINT_2D_INSTANTIATE(T) \ 00030 template class bugl_gaussian_point_2d<T > 00031 00032 #endif // bugl_gaussian_point_2d_txx_