Biorbd
Geometry.h
1 #ifndef BIORBD_MUSCLES_GEOMETRY_H
2 #define BIORBD_MUSCLES_GEOMETRY_H
3 
4 #include <vector>
5 #include <memory>
6 #include "biorbdConfig.h"
7 #include "Utils/Scalar.h"
8 
9 namespace biorbd {
10 namespace utils {
11 class Matrix;
12 class Vector;
13 class Vector3d;
14 }
15 
16 namespace rigidbody {
17 class Joints;
18 class GeneralizedCoordinates;
19 class GeneralizedVelocity;
20 }
21 
22 namespace muscles {
23 class PathModifiers;
24 class Characteristics;
25 
29 class BIORBD_API Geometry
30 {
31 public:
35  Geometry();
36 
42  Geometry(
43  const biorbd::utils::Vector3d &origin,
44  const biorbd::utils::Vector3d &insertion);
45 
50  biorbd::muscles::Geometry DeepCopy() const;
51 
56  void DeepCopy(
57  const biorbd::muscles::Geometry& other);
58 
68  void updateKinematics(
71  const biorbd::rigidbody::GeneralizedVelocity* Qdot = nullptr,
72  int updateKin = 2);
73 
85  void updateKinematics(
87  const biorbd::muscles::Characteristics& characteristics,
88  biorbd::muscles::PathModifiers& pathModifiers,
90  const biorbd::rigidbody::GeneralizedVelocity* Qdot = nullptr,
91  int updateKin = 2);
92 
101  void updateKinematics(
102  std::vector<biorbd::utils::Vector3d>& musclePointsInGlobal,
103  biorbd::utils::Matrix& jacoPointsInGlobal,
104  const biorbd::rigidbody::GeneralizedVelocity* Qdot = nullptr);
105 
115  void updateKinematics(
116  std::vector<biorbd::utils::Vector3d>& musclePointsInGlobal,
117  biorbd::utils::Matrix& jacoPointsInGlobal,
118  const biorbd::muscles::Characteristics& characteristics,
119  const biorbd::rigidbody::GeneralizedVelocity* Qdot = nullptr);
120 
125  void setOrigin(
126  const biorbd::utils::Vector3d &position);
127 
132  const biorbd::utils::Vector3d& originInLocal() const;
133 
138  void setInsertionInLocal(
139  const biorbd::utils::Vector3d &position);
140 
145  const biorbd::utils::Vector3d& insertionInLocal() const;
146 
153  const biorbd::utils::Vector3d& originInGlobal() const;
154 
161  const biorbd::utils::Vector3d& insertionInGlobal() const;
162 
169  const std::vector<biorbd::utils::Vector3d>& musclesPointsInGlobal() const;
170 
175  const biorbd::utils::Scalar& length() const;
176 
181  const biorbd::utils::Scalar& musculoTendonLength() const;
182 
187  const biorbd::utils::Scalar& velocity() const;
188 
193  const biorbd::utils::Matrix& jacobian() const;
194 
199  biorbd::utils::Matrix jacobianOrigin() const;
200 
205  biorbd::utils::Matrix jacobianInsertion() const ;
206 
212  biorbd::utils::Matrix jacobian(
213  unsigned int idxViaPoint) const;
214 
219  const biorbd::utils::Matrix& jacobianLength() const;
220 
221 
222 protected:
229  void _updateKinematics(
231  const biorbd::muscles::Characteristics* characteristics = nullptr,
232  biorbd::muscles::PathModifiers* pathModifiers = nullptr);
233 
240  const biorbd::utils::Vector3d& originInGlobal(
243 
250  const biorbd::utils::Vector3d& insertionInGlobal(
253 
258  void setMusclesPointsInGlobal(
259  std::vector<biorbd::utils::Vector3d>& ptsInGlobal);
260 
267  void setMusclesPointsInGlobal(
270  biorbd::muscles::PathModifiers* pathModifiers = nullptr);
271 
272 
279  const biorbd::utils::Scalar& length(
280  const biorbd::muscles::Characteristics* characteristics = nullptr,
281  biorbd::muscles::PathModifiers* pathModifiers = nullptr);
282 
288  const biorbd::utils::Scalar& velocity(
290 
295  void setJacobianDimension(
297 
302  void jacobian(
303  const biorbd::utils::Matrix &jaco);
304 
310  void jacobian(
313 
317  void computeJacobianLength();
318 
319  // Position des nodes dans le repere local
320  std::shared_ptr<biorbd::utils::Vector3d> m_origin;
321  std::shared_ptr<biorbd::utils::Vector3d> m_insertion;
322 
323  std::shared_ptr<biorbd::utils::Vector3d> m_originInGlobal;
324  std::shared_ptr<biorbd::utils::Vector3d> m_insertionInGlobal;
325  std::shared_ptr<std::vector<biorbd::utils::Vector3d>> m_pointsInGlobal;
326  std::shared_ptr<std::vector<biorbd::utils::Vector3d>> m_pointsInLocal;
327  std::shared_ptr<biorbd::utils::Matrix> m_jacobian;
328  std::shared_ptr<biorbd::utils::Matrix> m_G;
329  std::shared_ptr<biorbd::utils::Matrix> m_jacobianLength;
330 
331  std::shared_ptr<biorbd::utils::Scalar> m_length;
332  std::shared_ptr<biorbd::utils::Scalar> m_muscleTendonLength;
333  std::shared_ptr<biorbd::utils::Scalar> m_velocity;
334 
335  std::shared_ptr<bool> m_isGeometryComputed;
336  std::shared_ptr<bool> m_isVelocityComputed;
337  std::shared_ptr<bool> m_posAndJacoWereForced;
338 
339 };
340 
341 }}
342 
343 #endif // BIORBD_MUSCLES_GEOMETRY_H
biorbd::muscles::Geometry::m_originInGlobal
std::shared_ptr< biorbd::utils::Vector3d > m_originInGlobal
Position of the origin in the global reference.
Definition: Geometry.h:323
biorbd::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition: Vector3d.h:24
biorbd::muscles::Geometry::m_velocity
std::shared_ptr< biorbd::utils::Scalar > m_velocity
Velocity of the muscular elongation.
Definition: Geometry.h:333
biorbd::rigidbody::GeneralizedCoordinates
Class GeneralizedCoordinates.
Definition: GeneralizedCoordinates.h:15
biorbd::muscles::Geometry::m_pointsInGlobal
std::shared_ptr< std::vector< biorbd::utils::Vector3d > > m_pointsInGlobal
Position of all the points in the global reference.
Definition: Geometry.h:325
biorbd::muscles::Geometry::m_origin
std::shared_ptr< biorbd::utils::Vector3d > m_origin
Origin node.
Definition: Geometry.h:320
biorbd::muscles::Geometry
Class Geometry of the muscle.
Definition: Geometry.h:30
biorbd::muscles::Geometry::m_posAndJacoWereForced
std::shared_ptr< bool > m_posAndJacoWereForced
To know if the override was used on the muscle position and the Jacobian.
Definition: Geometry.h:337
biorbd::muscles::Geometry::m_G
std::shared_ptr< biorbd::utils::Matrix > m_G
Internal matrix of the jacobian dimension to speed up calculation.
Definition: Geometry.h:328
biorbd::muscles::Geometry::m_jacobianLength
std::shared_ptr< biorbd::utils::Matrix > m_jacobianLength
The muscle length jacobian.
Definition: Geometry.h:329
biorbd::muscles::Geometry::m_isVelocityComputed
std::shared_ptr< bool > m_isVelocityComputed
To know if the velocity was computed in the last update.
Definition: Geometry.h:336
biorbd::rigidbody::Joints
This is the core of the musculoskeletal model in biorbd.
Definition: Joints.h:40
biorbd::muscles::Geometry::m_jacobian
std::shared_ptr< biorbd::utils::Matrix > m_jacobian
The jacobian matrix.
Definition: Geometry.h:327
biorbd::muscles::PathModifiers
Holder of all the path modifiers of a muscle.
Definition: PathModifiers.h:18
biorbd::utils::Matrix
A wrapper for the Eigen::MatrixXd.
Definition: Matrix.h:21
biorbd::muscles::Geometry::m_insertion
std::shared_ptr< biorbd::utils::Vector3d > m_insertion
Insertion node.
Definition: Geometry.h:321
biorbd::muscles::Geometry::m_length
std::shared_ptr< biorbd::utils::Scalar > m_length
Muscle length.
Definition: Geometry.h:331
biorbd::muscles::Geometry::m_pointsInLocal
std::shared_ptr< std::vector< biorbd::utils::Vector3d > > m_pointsInLocal
Position of all the points in local.
Definition: Geometry.h:326
biorbd::muscles::Geometry::m_insertionInGlobal
std::shared_ptr< biorbd::utils::Vector3d > m_insertionInGlobal
Position of the insertion node in the global reference.
Definition: Geometry.h:324
biorbd::muscles::Geometry::m_muscleTendonLength
std::shared_ptr< biorbd::utils::Scalar > m_muscleTendonLength
Muscle tendon length.
Definition: Geometry.h:332
biorbd::muscles::Characteristics
Class Holds that muscle characteristics.
Definition: Characteristics.h:17
biorbd::rigidbody::GeneralizedVelocity
Class GeneralizedVelocity.
Definition: GeneralizedVelocity.h:15
biorbd::muscles::Geometry::m_isGeometryComputed
std::shared_ptr< bool > m_isGeometryComputed
To know if the geometry was computed at least once.
Definition: Geometry.h:335