// 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 "project_isometrically_to_plane.h" #include "edge_lengths.h" template < typename DerivedV, typename DerivedF, typename DerivedU, typename DerivedUF, typename Scalar> IGL_INLINE void igl::project_isometrically_to_plane( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, Eigen::PlainObjectBase & U, Eigen::PlainObjectBase & UF, Eigen::SparseMatrix& I) { using namespace std; using namespace Eigen; assert(F.cols() == 3 && "F should contain triangles"); typedef DerivedV MatrixX; MatrixX l; edge_lengths(V,F,l); // Number of faces const int m = F.rows(); // First corner at origin U = DerivedU::Zero(m*3,2); // Second corner along x-axis U.block(m,0,m,1) = l.col(2); // Third corner rotated onto plane U.block(m*2,0,m,1) = (-l.col(0).array().square() + l.col(1).array().square() + l.col(2).array().square())/(2.*l.col(2).array()); U.block(m*2,1,m,1) = (l.col(1).array().square()-U.block(m*2,0,m,1).array().square()).sqrt(); typedef Triplet IJV; vector ijv; ijv.reserve(3*m); UF.resize(m,3); for(int f = 0;f, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, double>(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::SparseMatrix&); #endif