// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2022 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 "moments.h" // C++17 would avoid this with an if constexpr below // // This makes it so that m1 can be: // - RowVector3d // - Vector3d // - RowVectorXd // - VectorXd namespace igl { template struct moments_resize_3; template <> struct moments_resize_3 { template static void run(Eigen::PlainObjectBase& m1) { static_assert(Derivedm1::ColsAtCompileTime == Eigen::Dynamic || Derivedm1::ColsAtCompileTime == 3,"#cols must be 3 or dynamic"); m1.resize(1,3); } }; template <> struct moments_resize_3 { template static void run(Eigen::PlainObjectBase& m1) { static_assert(Derivedm1::RowsAtCompileTime == Eigen::Dynamic || Derivedm1::RowsAtCompileTime == 3,"#rows must be 3 or dynamic"); m1.resize(3,1); } }; } template < typename DerivedV, typename DerivedF, typename Derivedm0, typename Derivedm1, typename Derivedm2> IGL_INLINE void igl::moments( const Eigen::MatrixBase& V, const Eigen::MatrixBase& F, Derivedm0 & m0, Eigen::PlainObjectBase& m1, Eigen::PlainObjectBase& m2) { assert(V.cols() == 3 && "V should be #V by 3"); typedef typename Derivedm2::Scalar Scalar; m0 = 0; moments_resize_3::run(m1); m1 << 0,0,0; Scalar _xx=0; Scalar _yy=0; Scalar _zz=0; Scalar _yx=0; Scalar _zx=0; Scalar _zy=0; for(int f = 0;f, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::moments, Eigen::Matrix, double, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif