circumradius.cpp 943 B

1234567891011121314151617181920212223242526
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "circumradius.h"
  9. #include "edge_lengths.h"
  10. #include "doublearea.h"
  11. template <
  12. typename DerivedV,
  13. typename DerivedF,
  14. typename DerivedR>
  15. IGL_INLINE void igl::circumradius(
  16. const Eigen::PlainObjectBase<DerivedV> & V,
  17. const Eigen::PlainObjectBase<DerivedF> & F,
  18. Eigen::PlainObjectBase<DerivedR> & R)
  19. {
  20. Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,3> l;
  21. igl::edge_lengths(V,F,l);
  22. DerivedR A;
  23. igl::doublearea(l,0.,A);
  24. // use formula: R=abc/(4*area) to compute the circum radius
  25. R = l.col(0).array() * l.col(1).array() * l.col(2).array() / (2.0*A.array());
  26. }