// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2014 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "volume.h" #include "cross.h" #include template < typename DerivedV, typename DerivedT, typename Derivedvol> IGL_INLINE void igl::volume( const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& T, Eigen::PlainObjectBase& vol) { using namespace Eigen; const int m = T.rows(); vol.resize(m,1); for(int t = 0;t IGL_INLINE void igl::volume( const Eigen::PlainObjectBase & A, const Eigen::PlainObjectBase & B, const Eigen::PlainObjectBase & C, const Eigen::PlainObjectBase & D, Eigen::PlainObjectBase & vol) { const auto & AmD = A-D; const auto & BmD = B-D; const auto & CmD = C-D; DerivedA BmDxCmD; cross(BmD.eval(),CmD.eval(),BmDxCmD); const auto & AmDdx = (AmD.array() * BmDxCmD.array()).rowwise().sum(); vol = -AmDdx/6.; } template < typename VecA, typename VecB, typename VecC, typename VecD> IGL_INLINE typename VecA::Scalar igl::volume_single( const VecA & a, const VecB & b, const VecC & c, const VecD & d) { return -(a-d).dot((b-d).cross(c-d))/6.; } template < typename DerivedL, typename Derivedvol> IGL_INLINE void igl::volume( const Eigen::PlainObjectBase& L, Eigen::PlainObjectBase& vol) { using namespace Eigen; const int m = L.rows(); typedef typename Derivedvol::Scalar ScalarS; vol.resize(m,1); for(int t = 0;t, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template Eigen::Matrix::Scalar igl::volume_single, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&); template Eigen::Matrix::Scalar igl::volume_single, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&); template void igl::volume, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template void igl::volume, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif