Biorbd
SegmentCharacteristics.cpp
1 #define BIORBD_API_EXPORTS
2 #include "RigidBody/SegmentCharacteristics.h"
3 
4 #include "Utils/Vector3d.h"
5 #include "RigidBody/MeshFace.h"
6 #include "RigidBody/Mesh.h"
7 
9  Body(),
10  m_length(std::make_shared<biorbd::utils::Scalar>(0)),
11  m_mesh(std::make_shared<biorbd::rigidbody::Mesh>())
12 {
13 
14 }
16  double mass,
17  const biorbd::utils::Vector3d &com,
18  const RigidBodyDynamics::Math::Matrix3d &inertia) :
19  Body(mass, com, inertia),
20  m_length(std::make_shared<biorbd::utils::Scalar>(0)),
21  m_mesh(std::make_shared<biorbd::rigidbody::Mesh>())
22 {
23 
24 }
26  double mass,
27  const biorbd::utils::Vector3d &com,
28  const RigidBodyDynamics::Math::Matrix3d &inertia,
29  const biorbd::rigidbody::Mesh &mesh) :
30  Body(mass, com, inertia),
31  m_length(std::make_shared<biorbd::utils::Scalar>(0)),
32  m_mesh(std::make_shared<biorbd::rigidbody::Mesh>(mesh))
33 {
34 
35 }
36 
38 {
40  copy.DeepCopy(*this);
41  return copy;
42 }
43 
45 {
46  static_cast<RigidBodyDynamics::Body&>(*this) = other;
47  *m_length = *other.m_length;
48  *m_mesh = other.m_mesh->DeepCopy();
49 }
50 
52  const biorbd::utils::Scalar& val)
53 {
54  *m_length = val;
55 }
56 
57 const biorbd::utils::Scalar& biorbd::rigidbody::SegmentCharacteristics::length() const
58 {
59  return *m_length;
60 }
61 
63 {
64  return mMass;
65 }
66 
68 {
69  return mCenterOfMass;
70 }
71 
73  const biorbd::utils::Vector3d &com)
74 {
75  mCenterOfMass = com;
76 }
77 
79 {
80  return *m_mesh;
81 }
82 
83 const RigidBodyDynamics::Math::Matrix3d &biorbd::rigidbody::SegmentCharacteristics::inertia() const
84 {
85  return mInertia;
86 }
biorbd::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition: Vector3d.h:24
biorbd::rigidbody::SegmentCharacteristics
Characteristics of a segment, namely the mass, the center of mass, the inertia, the length and its me...
Definition: SegmentCharacteristics.h:27
biorbd::rigidbody::SegmentCharacteristics::m_length
std::shared_ptr< biorbd::utils::Scalar > m_length
Length of the segment.
Definition: SegmentCharacteristics.h:114
biorbd::rigidbody::SegmentCharacteristics::m_mesh
std::shared_ptr< biorbd::rigidbody::Mesh > m_mesh
Mesh of the segment.
Definition: SegmentCharacteristics.h:115
biorbd::rigidbody::SegmentCharacteristics::DeepCopy
biorbd::rigidbody::SegmentCharacteristics DeepCopy() const
Deep copy of the segment characteristics.
Definition: SegmentCharacteristics.cpp:37
biorbd::rigidbody::SegmentCharacteristics::setCoM
void setCoM(const biorbd::utils::Vector3d &com)
setCoM Change the position of the center of mass
Definition: SegmentCharacteristics.cpp:72
biorbd::rigidbody::Mesh
A class that holds the geometry of a segment.
Definition: Mesh.h:21
biorbd::rigidbody::SegmentCharacteristics::setLength
void setLength(const biorbd::utils::Scalar &val)
Set the segment length.
Definition: SegmentCharacteristics.cpp:51
biorbd::rigidbody::SegmentCharacteristics::SegmentCharacteristics
SegmentCharacteristics()
Construct segment characteristics.
Definition: SegmentCharacteristics.cpp:8
biorbd::rigidbody::SegmentCharacteristics::mass
double mass() const
Returns the segment mass.
Definition: SegmentCharacteristics.cpp:62
biorbd::rigidbody::SegmentCharacteristics::CoM
biorbd::utils::Vector3d CoM() const
CoM Returns the position of the center of mass in the local reference frame.
Definition: SegmentCharacteristics.cpp:67
biorbd::rigidbody::SegmentCharacteristics::length
const biorbd::utils::Scalar & length() const
Returns the segment length.
Definition: SegmentCharacteristics.cpp:57
biorbd::rigidbody::SegmentCharacteristics::inertia
const RigidBodyDynamics::Math::Matrix3d & inertia() const
Returns the segment inertia matrix.
Definition: SegmentCharacteristics.cpp:83
biorbd::rigidbody::SegmentCharacteristics::mesh
const biorbd::rigidbody::Mesh & mesh() const
Returns the segment mesh.
Definition: SegmentCharacteristics.cpp:78