$search
00001 00016 /***************************************************************************** 00017 ** Ifdefs 00018 *****************************************************************************/ 00019 00020 #ifndef ECL_STATISTICS_COVARIANCE_ELLIPSOID_HPP_ 00021 #define ECL_STATISTICS_COVARIANCE_ELLIPSOID_HPP_ 00022 00023 /***************************************************************************** 00024 ** Includes 00025 *****************************************************************************/ 00026 00027 #include <cmath> 00028 #include <ecl/linear_algebra.hpp> 00029 #include <ecl/config/macros.hpp> 00030 00031 /***************************************************************************** 00032 ** Namespaces 00033 *****************************************************************************/ 00034 00035 namespace ecl { 00036 00037 /***************************************************************************** 00038 ** Interface [CovarianceEllipsoid] 00039 *****************************************************************************/ 00047 template<typename T, int N> 00048 class ECL_PUBLIC CovarianceEllipsoid { 00049 private: 00056 CovarianceEllipsoid() {}; 00057 virtual ~CovarianceEllipsoid() {}; 00058 }; 00059 00060 /***************************************************************************** 00061 ** Interface [CovarianceEllipsoid2f] 00062 *****************************************************************************/ 00098 template<> 00099 class ECL_PUBLIC CovarianceEllipsoid<float,2> { 00100 public: 00107 CovarianceEllipsoid(); 00108 00118 CovarianceEllipsoid(const ecl::linear_algebra::Matrix2f& M); 00119 00120 virtual ~CovarianceEllipsoid() {}; 00121 00131 void compute(const ecl::linear_algebra::Matrix2f& M); 00132 00140 const ecl::linear_algebra::Vector2f& lengths() { return ellipse_lengths; } 00148 const ecl::linear_algebra::Matrix2f& axes() { return ellipse_axes; } 00149 00158 double rotation(); 00174 ecl::linear_algebra::Vector2f intercepts(); 00175 00176 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00177 00178 private: 00179 ecl::linear_algebra::Vector2f ellipse_lengths; 00180 ecl::linear_algebra::Matrix2f ellipse_axes; 00181 }; 00182 00183 00184 00216 template<> 00217 class ECL_PUBLIC CovarianceEllipsoid<float,3> { 00218 public: 00225 CovarianceEllipsoid(); 00226 00237 CovarianceEllipsoid(const ecl::linear_algebra::Matrix3f& M, const bool sort = true); 00238 00239 virtual ~CovarianceEllipsoid() {}; 00240 00254 void compute(const ecl::linear_algebra::Matrix3f& M, const bool sort = true); 00255 00263 const ecl::linear_algebra::Vector3f& lengths() { return ellipse_lengths; } 00272 const ecl::linear_algebra::Matrix3f& axes() { return ellipse_axes; } 00273 00274 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00275 00276 private: 00277 ecl::linear_algebra::Vector3f ellipse_lengths; 00278 ecl::linear_algebra::Matrix3f ellipse_axes; 00279 }; 00280 00281 /***************************************************************************** 00282 ** Interface [CovarianceEllipsoid2d] 00283 *****************************************************************************/ 00319 template<> 00320 class ECL_PUBLIC CovarianceEllipsoid<double,2> { 00321 public: 00328 CovarianceEllipsoid(); 00329 00339 CovarianceEllipsoid(const ecl::linear_algebra::Matrix2d& M); 00340 00341 virtual ~CovarianceEllipsoid() {}; 00342 00352 void compute(const ecl::linear_algebra::Matrix2d& M); 00353 00361 const ecl::linear_algebra::Vector2d& lengths() { return ellipse_lengths; } 00369 const ecl::linear_algebra::Matrix2d& axes() { return ellipse_axes; } 00370 00379 double rotation(); 00395 ecl::linear_algebra::Vector2d intercepts(); 00396 00397 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00398 00399 private: 00400 ecl::linear_algebra::Vector2d ellipse_lengths; 00401 ecl::linear_algebra::Matrix2d ellipse_axes; 00402 }; 00403 00404 00405 00437 template<> 00438 class ECL_PUBLIC CovarianceEllipsoid<double,3> { 00439 public: 00446 CovarianceEllipsoid(); 00447 00458 CovarianceEllipsoid(const ecl::linear_algebra::Matrix3d& M, const bool sort = true); 00459 00460 virtual ~CovarianceEllipsoid() {}; 00461 00475 void compute(const ecl::linear_algebra::Matrix3d& M, const bool sort = true); 00476 00484 const ecl::linear_algebra::Vector3d& lengths() { return ellipse_lengths; } 00493 const ecl::linear_algebra::Matrix3d& axes() { return ellipse_axes; } 00494 00495 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00496 00497 private: 00498 ecl::linear_algebra::Vector3d ellipse_lengths; 00499 ecl::linear_algebra::Matrix3d ellipse_axes; 00500 }; 00501 00502 /***************************************************************************** 00503 ** Convenience Typedefs 00504 *****************************************************************************/ 00512 typedef CovarianceEllipsoid<float,2> CovarianceEllipsoid2f; 00520 typedef CovarianceEllipsoid<double,2> CovarianceEllipsoid2d; 00528 typedef CovarianceEllipsoid<float,3> CovarianceEllipsoid3f; 00529 00537 typedef CovarianceEllipsoid<double,3> CovarianceEllipsoid3d; 00538 00539 00540 } // namespace ecl 00541 00542 #endif /* ECL_STATISTICS_COVARIANCE_ELLIPSOID_HPP_ */