|
@@ -14,8 +14,8 @@ template <
|
|
|
typename Derivedc,
|
|
|
typename Derivedvol>
|
|
|
IGL_INLINE void igl::centroid(
|
|
|
- const Eigen::PlainObjectBase<DerivedV>& V,
|
|
|
- const Eigen::PlainObjectBase<DerivedF>& F,
|
|
|
+ const Eigen::MatrixBase<DerivedV>& V,
|
|
|
+ const Eigen::MatrixBase<DerivedF>& F,
|
|
|
Eigen::PlainObjectBase<Derivedc>& cen,
|
|
|
Derivedvol & vol)
|
|
|
{
|
|
@@ -31,11 +31,12 @@ IGL_INLINE void igl::centroid(
|
|
|
// "Calculating the volume and centroid of a polyhedron in 3d" [Nuernberg 2013]
|
|
|
// http://www2.imperial.ac.uk/~rn/centroid.pdf
|
|
|
// rename corners
|
|
|
- const RowVector3d & a = V.row(F(f,0));
|
|
|
- const RowVector3d & b = V.row(F(f,1));
|
|
|
- const RowVector3d & c = V.row(F(f,2));
|
|
|
+ typedef Eigen::Matrix<typename DerivedV::Scalar,1,3> RowVector3S;
|
|
|
+ const RowVector3S & a = V.row(F(f,0));
|
|
|
+ const RowVector3S & b = V.row(F(f,1));
|
|
|
+ const RowVector3S & c = V.row(F(f,2));
|
|
|
// un-normalized normal
|
|
|
- const RowVector3d & n = (b-a).cross(c-a);
|
|
|
+ const RowVector3S & n = (b-a).cross(c-a);
|
|
|
// total volume via divergence theorem: ∫ 1
|
|
|
vol += n.dot(a)/6.;
|
|
|
// centroid via divergence theorem and midpoint quadrature: ∫ x
|
|
@@ -50,8 +51,8 @@ template <
|
|
|
typename DerivedF,
|
|
|
typename Derivedc>
|
|
|
IGL_INLINE void igl::centroid(
|
|
|
- const Eigen::PlainObjectBase<DerivedV>& V,
|
|
|
- const Eigen::PlainObjectBase<DerivedF>& F,
|
|
|
+ const Eigen::MatrixBase<DerivedV>& V,
|
|
|
+ const Eigen::MatrixBase<DerivedF>& F,
|
|
|
Eigen::PlainObjectBase<Derivedc>& c)
|
|
|
{
|
|
|
typename Derivedc::Scalar vol;
|
|
@@ -59,5 +60,8 @@ IGL_INLINE void igl::centroid(
|
|
|
}
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
-template void igl::centroid<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
|
|
+// Explicit template instantiation
|
|
|
+// generated by autoexplicit.sh
|
|
|
+template void igl::centroid<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<float, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&);
|
|
|
+template void igl::centroid<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
|
|
#endif
|