// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 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 "hausdorff.h" #include "point_mesh_squared_distance.h" template < typename DerivedVA, typename DerivedFA, typename DerivedVB, typename DerivedFB, typename Scalar> IGL_INLINE void igl::hausdorff( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, const Eigen::PlainObjectBase & FB, Scalar & d) { using namespace Eigen; assert(VA.cols() == 3 && "VA should contain 3d points"); assert(FA.cols() == 3 && "FA should contain triangles"); assert(VB.cols() == 3 && "VB should contain 3d points"); assert(FB.cols() == 3 && "FB should contain triangles"); Matrix sqr_DBA,sqr_DAB; Matrix I; Matrix C; point_mesh_squared_distance(VB,VA,FA,sqr_DBA,I,C); point_mesh_squared_distance(VA,VB,FB,sqr_DAB,I,C); const Scalar dba = sqr_DBA.maxCoeff(); const Scalar dab = sqr_DAB.maxCoeff(); d = sqrt(std::max(dba,dab)); }