forward_kinematics.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifndef IGL_FORWARD_KINEMATICS_H
  9. #define IGL_FORWARD_KINEMATICS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Geometry>
  13. #include <Eigen/StdVector>
  14. #include <vector>
  15. namespace igl
  16. {
  17. // Given a skeleton and a set of relative bone rotations compute absolute
  18. // rigid transformations for each bone.
  19. //
  20. // Inputs:
  21. // C #C by dim list of joint positions
  22. // BE #BE by 2 list of bone edge indices
  23. // P #BE list of parent indices into BE
  24. // dQ #BE list of relative rotations
  25. // dT #BE list of relative translations
  26. // Outputs:
  27. // vQ #BE list of absolute rotations
  28. // vT #BE list of absolute translations
  29. IGL_INLINE void forward_kinematics(
  30. const Eigen::MatrixXd & C,
  31. const Eigen::MatrixXi & BE,
  32. const Eigen::VectorXi & P,
  33. const std::vector<
  34. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & dQ,
  35. const std::vector<Eigen::Vector3d> & dT,
  36. std::vector<
  37. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & vQ,
  38. std::vector<Eigen::Vector3d> & vT);
  39. // Wrapper assuming each dT[i] == {0,0,0}
  40. IGL_INLINE void forward_kinematics(
  41. const Eigen::MatrixXd & C,
  42. const Eigen::MatrixXi & BE,
  43. const Eigen::VectorXi & P,
  44. const std::vector<
  45. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & dQ,
  46. std::vector<
  47. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & vQ,
  48. std::vector<Eigen::Vector3d> & vT);
  49. // Outputs:
  50. // T #BE*(dim+1) by dim stack of transposed transformation matrices
  51. IGL_INLINE void forward_kinematics(
  52. const Eigen::MatrixXd & C,
  53. const Eigen::MatrixXi & BE,
  54. const Eigen::VectorXi & P,
  55. const std::vector<
  56. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & dQ,
  57. const std::vector<Eigen::Vector3d> & dT,
  58. Eigen::MatrixXd & T);
  59. IGL_INLINE void forward_kinematics(
  60. const Eigen::MatrixXd & C,
  61. const Eigen::MatrixXi & BE,
  62. const Eigen::VectorXi & P,
  63. const std::vector<
  64. Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > & dQ,
  65. Eigen::MatrixXd & T);
  66. };
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "forward_kinematics.cpp"
  69. #endif
  70. #endif