// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2020 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 "bezier.h" #include // Adapted from main.c accompanying // An Algorithm for Automatically Fitting Digitized Curves // by Philip J. Schneider // from "Graphics Gems", Academic Press, 1990 template IGL_INLINE void igl::bezier( const Eigen::MatrixBase & V, const typename DerivedV::Scalar t, Eigen::PlainObjectBase & P) { // working local copy DerivedV Vtemp = V; int degree = Vtemp.rows()-1; /* Triangle computation */ for (int i = 1; i <= degree; i++) { for (int j = 0; j <= degree-i; j++) { Vtemp.row(j) = ((1.0 - t) * Vtemp.row(j) + t * Vtemp.row(j+1)).eval(); } } P = Vtemp.row(0); } template IGL_INLINE void igl::bezier( const Eigen::MatrixBase & V, const Eigen::MatrixBase & T, Eigen::PlainObjectBase & P) { P.resize(T.size(),V.cols()); for(int i = 0;i Pi; bezier(V,T(i),Pi); P.row(i) = Pi; } } template IGL_INLINE void igl::bezier( const std::vector & spline, const Eigen::MatrixBase & T, Eigen::PlainObjectBase & P) { if(spline.size() == 0) return; const int m = T.rows(); const int dim = spline[0].cols(); P.resize(m*spline.size(),dim); for(int c = 0;c, Eigen::Matrix, Eigen::Matrix >(std::vector, std::allocator > > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template void igl::bezier, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&); template void igl::bezier, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::Matrix::Scalar, Eigen::PlainObjectBase >&); #endif