Biorbd
RotoTrans.h
1 #ifndef BIORBD_UTILS_ROTO_TRANS_H
2 #define BIORBD_UTILS_ROTO_TRANS_H
3 
4 #include <vector>
5 #include <memory>
6 #include "rbdl_math.h"
7 #include "Utils/Scalar.h"
8 
9 namespace RigidBodyDynamics { namespace Math {
10 struct SpatialTransform;
11 }}
12 
13 #include "biorbdConfig.h"
14 
15 namespace biorbd {
16 namespace rigidbody {
17 class NodeSegment;
18 }
19 
20 namespace utils {
21 class String;
22 class Vector;
23 class Rotation;
24 class Vector3d;
25 
29 #ifdef SWIG
30 class BIORBD_API RotoTrans
31 #else
32 class BIORBD_API RotoTrans : public RigidBodyDynamics::Math::Matrix4d
33 #endif
34 {
35 public:
40  RotoTrans(
41  const RigidBodyDynamics::Math::Matrix4d& matrix = RigidBodyDynamics::Math::Matrix4d::Identity());
42 
62  RotoTrans(
63  const biorbd::utils::Scalar& v00, const biorbd::utils::Scalar& v01, const biorbd::utils::Scalar& v02, const biorbd::utils::Scalar& v03,
64  const biorbd::utils::Scalar& v10, const biorbd::utils::Scalar& v11, const biorbd::utils::Scalar& v12, const biorbd::utils::Scalar& v13,
65  const biorbd::utils::Scalar& v20, const biorbd::utils::Scalar& v21, const biorbd::utils::Scalar& v22, const biorbd::utils::Scalar& v23,
66  const biorbd::utils::Scalar& v30, const biorbd::utils::Scalar& v31, const biorbd::utils::Scalar& v32, const biorbd::utils::Scalar& v33);
67 
72  RotoTrans(
73  const biorbd::utils::Rotation& rot);
74 
80  RotoTrans(
81  const biorbd::utils::Rotation& rot,
82  const biorbd::utils::Vector3d& trans);
83 
93  RotoTrans(
94  const biorbd::utils::Vector& rotation,
95  const biorbd::utils::Vector3d& translation,
96  const biorbd::utils::String &rotationSequence);
97 
102  RotoTrans(
103  const RigidBodyDynamics::Math::SpatialTransform& st);
104 
105 #ifdef BIORBD_USE_EIGEN3_MATH
106 
111  template<typename OtherDerived> RotoTrans(
112  const Eigen::MatrixBase<OtherDerived>& other) :
113  RigidBodyDynamics::Math::Matrix4d(other){
114  checkUnitary();
115  }
116 
117 #endif
118 
128  static biorbd::utils::RotoTrans fromMarkers(
129  const biorbd::rigidbody::NodeSegment& origin,
130  const std::pair<biorbd::rigidbody::NodeSegment, biorbd::rigidbody::NodeSegment>& axis1markers,
131  const std::pair<biorbd::rigidbody::NodeSegment, biorbd::rigidbody::NodeSegment>& axis2markers,
132  const std::pair<biorbd::utils::String, biorbd::utils::String> &axesNames,
133  const biorbd::utils::String& axisToRecalculate);
134 
141  unsigned int idx) const ;
142 
147  biorbd::utils::RotoTrans transpose() const;
148 
153  biorbd::utils::Vector3d trans() const;
154 
159  biorbd::utils::Rotation rot() const;
160 
167  static biorbd::utils::RotoTrans combineRotAndTrans(
168  const biorbd::utils::Rotation& rot,
169  const biorbd::utils::Vector3d& trans);
170 
176  static biorbd::utils::RotoTrans fromSpatialTransform(
177  const RigidBodyDynamics::Math::SpatialTransform& st);
178 
188  static biorbd::utils::RotoTrans fromEulerAngles(
189  const biorbd::utils::Vector &rot,
190  const biorbd::utils::Vector3d& trans,
191  const biorbd::utils::String& seq);
192 
201  static biorbd::utils::Vector toEulerAngles(
202  const biorbd::utils::RotoTrans& rt,
203  const biorbd::utils::String &seq);
204 
205 #ifndef BIORBD_USE_CASADI_MATH
206  static biorbd::utils::RotoTrans mean(
212  const std::vector<biorbd::utils::RotoTrans>&rt);
213 #endif
214 
215 #ifndef SWIG
216 #ifdef BIORBD_USE_EIGEN3_MATH
217  template<typename OtherDerived>
222  biorbd::utils::RotoTrans& operator=(const Eigen::MatrixBase <OtherDerived>& other){
223  Eigen::Matrix4d::operator=(other);
224  return *this;
225  }
226 #endif
227 #endif
228 
229 protected:
234  RigidBodyDynamics::Math::Vector4d expand3dTo4d(const biorbd::utils::Vector3d& v1);
235 
241  void checkUnitary();
242 };
243 
244 }}
245 
246 #ifndef SWIG
247 std::ostream& operator<<(std::ostream& os, const biorbd::utils::RotoTrans &rt);
253 #endif
254 
255 #endif // BIORBD_UTILS_ROTO_TRANS_H
biorbd::utils::Vector
Wrapper of the Eigen VectorXd.
Definition: Vector.h:20
biorbd::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition: Vector3d.h:24
biorbd::utils::RotoTrans
Homogenous matrix to describe translations and rotations simultaneously.
Definition: RotoTrans.h:34
biorbd::utils::Rotation
Rotation matrix.
Definition: Rotation.h:34
biorbd::utils::String
Wrapper around the std::string class with augmented functionality.
Definition: String.h:17
biorbd::rigidbody::NodeSegment
A point attached to a segment, generally speaking a skin marker.
Definition: NodeSegment.h:19