|
@@ -6,13 +6,15 @@
|
|
|
// 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 <Eigen/Geometry>
|
|
|
template <
|
|
|
typename DerivedV,
|
|
|
typename DerivedT,
|
|
|
typename Derivedvol>
|
|
|
IGL_INLINE void igl::volume(
|
|
|
- Eigen::PlainObjectBase<DerivedV>& V,
|
|
|
- Eigen::PlainObjectBase<DerivedT>& T,
|
|
|
+ const Eigen::PlainObjectBase<DerivedV>& V,
|
|
|
+ const Eigen::PlainObjectBase<DerivedT>& T,
|
|
|
Eigen::PlainObjectBase<Derivedvol>& vol)
|
|
|
{
|
|
|
using namespace Eigen;
|
|
@@ -28,11 +30,48 @@ IGL_INLINE void igl::volume(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+template <
|
|
|
+ typename DerivedA,
|
|
|
+ typename DerivedB,
|
|
|
+ typename DerivedC,
|
|
|
+ typename DerivedD,
|
|
|
+ typename Derivedvol>
|
|
|
+IGL_INLINE void igl::volume(
|
|
|
+ const Eigen::PlainObjectBase<DerivedA> & A,
|
|
|
+ const Eigen::PlainObjectBase<DerivedB> & B,
|
|
|
+ const Eigen::PlainObjectBase<DerivedC> & C,
|
|
|
+ const Eigen::PlainObjectBase<DerivedD> & D,
|
|
|
+ Eigen::PlainObjectBase<Derivedvol> & vol)
|
|
|
+{
|
|
|
+ const auto & AmD = A-D;
|
|
|
+ const auto & BmD = B-D;
|
|
|
+ const auto & CmD = C-D;
|
|
|
+ Eigen::PlainObjectBase<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(
|
|
|
- Eigen::PlainObjectBase<DerivedL>& L,
|
|
|
+ const Eigen::PlainObjectBase<DerivedL>& L,
|
|
|
Eigen::PlainObjectBase<Derivedvol>& vol)
|
|
|
{
|
|
|
using namespace Eigen;
|
|
@@ -68,5 +107,8 @@ IGL_INLINE void igl::volume(
|
|
|
#ifndef IGL_HEADER_ONLY
|
|
|
// Explicit template specialization
|
|
|
// generated by autoexplicit.sh
|
|
|
-template void igl::volume<Eigen::Matrix<double, -1, 6, 0, -1, 6>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 6, 0, -1, 6> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
|
|
+template void igl::volume<Eigen::Matrix<double, -1, 6, 0, -1, 6>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 6, 0, -1, 6> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
|
|
+template Eigen::Matrix<double, 1, 3, 1, 1, 3>::Scalar igl::volume_single<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&);
|
|
|
+template Eigen::Matrix<double, 3, 1, 0, 3, 1>::Scalar igl::volume_single<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&);
|
|
|
+template void igl::volume<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
|
|
#endif
|