// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2016 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 #include #include template IGL_INLINE void igl::sort_vectors_ccw( const Eigen::PlainObjectBase& P, const Eigen::PlainObjectBase& N, Eigen::PlainObjectBase &order) { int half_degree = P.cols()/3; //local frame Eigen::Matrix e1 = P.head(3).normalized(); Eigen::Matrix e3 = N.normalized(); Eigen::Matrix e2 = e3.cross(e1); Eigen::Matrix F; F< angles(half_degree,1); for (int i=0; i Pl = F.colPivHouseholderQr().solve(P.segment(i*3,3).transpose()).transpose(); // assert(fabs(Pl(2))/Pl.cwiseAbs().maxCoeff() <1e-5); angles[i] = atan2(Pl(1),Pl(0)); } igl::sort( angles, 1, true, angles, order); //make sure that the first element is always at the top while (order[0] != 0) { //do a circshift int temp = order[0]; for (int i =0; i< half_degree-1; ++i) order[i] = order[i+1]; order(half_degree-1) = temp; } } template IGL_INLINE void igl::sort_vectors_ccw( const Eigen::PlainObjectBase& P, const Eigen::PlainObjectBase& N, Eigen::PlainObjectBase &order, Eigen::PlainObjectBase &sorted) { int half_degree = P.cols()/3; igl::sort_vectors_ccw(P,N,order); sorted.resize(1,half_degree*3); for (int i=0; i IGL_INLINE void igl::sort_vectors_ccw( const Eigen::PlainObjectBase& P, const Eigen::PlainObjectBase& N, Eigen::PlainObjectBase &order, Eigen::PlainObjectBase &inv_order) { int half_degree = P.cols()/3; igl::sort_vectors_ccw(P,N,order); inv_order.resize(half_degree,1); for (int i=0; i IGL_INLINE void igl::sort_vectors_ccw( const Eigen::PlainObjectBase& P, const Eigen::PlainObjectBase& N, Eigen::PlainObjectBase &order, Eigen::PlainObjectBase &sorted, Eigen::PlainObjectBase &inv_order) { int half_degree = P.cols()/3; igl::sort_vectors_ccw(P,N,order,inv_order); sorted.resize(1,half_degree*3); for (int i=0; i, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template void igl::sort_vectors_ccw, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif