angular_distance.cpp 786 B

123456789101112131415161718192021
  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 "angular_distance.h"
  9. #include <igl/EPS.h>
  10. #include <igl/PI.h>
  11. IGL_INLINE double igl::angular_distance(
  12. const Eigen::Quaterniond & A,
  13. const Eigen::Quaterniond & B)
  14. {
  15. using namespace igl;
  16. assert(fabs(A.norm()-1)<FLOAT_EPS && "A should be unit norm");
  17. assert(fabs(B.norm()-1)<FLOAT_EPS && "B should be unit norm");
  18. //// acos is always in [0,2*pi)
  19. //return acos(fabs(A.dot(B)));
  20. return fmod(2.*acos(A.dot(B)),2.*PI);
  21. }