normalize_row_lengths.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "normalize_row_lengths.h"
  9. template <typename DerivedV>
  10. IGL_INLINE void igl::normalize_row_lengths(
  11. const Eigen::PlainObjectBase<DerivedV>& A,
  12. Eigen::PlainObjectBase<DerivedV> & B)
  13. {
  14. // Resize output
  15. B.resize(A.rows(),A.cols());
  16. // loop over rows
  17. for(int i = 0; i < A.rows();i++)
  18. {
  19. B.row(i) = A.row(i).normalized();
  20. }
  21. //// Or just:
  22. //B = A;
  23. //B.rowwise().normalize();
  24. }
  25. #ifdef IGL_STATIC_LIBRARY
  26. // Explicit template specialization
  27. // generated by autoexplicit.sh
  28. template void igl::normalize_row_lengths<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  29. template void igl::normalize_row_lengths<Eigen::Matrix<double, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
  30. template void igl::normalize_row_lengths<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
  31. #endif