Biorbd Release_1.13.0
Loading...
Searching...
No Matches
SegmentCharacteristics.cpp
1#define BIORBD_API_EXPORTS
2#include "RigidBody/SegmentCharacteristics.h"
3
4#include "RigidBody/Mesh.h"
5#include "RigidBody/MeshFace.h"
6#include "Utils/Matrix3d.h"
7#include "Utils/Scalar.h"
8#include "Utils/Vector3d.h"
9
10using namespace BIORBD_NAMESPACE;
11
13 : Body(),
14 m_length(std::make_shared<utils::Scalar>(0)),
15 m_mesh(std::make_shared<rigidbody::Mesh>()) {}
17 const utils::Scalar &mass,
18 const utils::Vector3d &com,
20 : Body(mass, com, inertia),
21 m_length(std::make_shared<utils::Scalar>(0)),
22 m_mesh(std::make_shared<rigidbody::Mesh>()) {}
24 const utils::Scalar &mass,
25 const utils::Vector3d &com,
27 const rigidbody::Mesh &mesh)
28 : Body(mass, com, inertia),
29 m_length(std::make_shared<utils::Scalar>(0)),
30 m_mesh(std::make_shared<rigidbody::Mesh>(mesh)) {}
31
38
40 const SegmentCharacteristics &other) {
41 static_cast<RigidBodyDynamics::Body &>(*this) = other;
42 *m_length = *other.m_length;
43 *m_mesh = other.m_mesh->DeepCopy();
44}
45
46void rigidbody::SegmentCharacteristics::setLength(const utils::Scalar &val) {
47 *m_length = val;
48}
49
51 return *m_length;
52}
53
54void rigidbody::SegmentCharacteristics::setMass(const utils::Scalar &newMass) {
55 mMass = newMass;
56}
57
58utils::Scalar rigidbody::SegmentCharacteristics::mass() const { return mMass; }
59
61 return mCenterOfMass;
62}
63
65 mCenterOfMass = com;
66}
67
69
73
75 return mInertia;
76}
77
A class that holds the geometry of a segment.
Definition Mesh.h:22
Characteristics of a segment, namely the mass, the center of mass, the inertia, the length and its me...
void setLength(const utils::Scalar &val)
Set the segment length.
std::shared_ptr< utils::Scalar > m_length
Length of the segment.
utils::Scalar length() const
Returns the segment length.
const utils::Matrix3d inertia() const
Returns the segment inertia matrix.
SegmentCharacteristics DeepCopy() const
Deep copy of the segment characteristics.
utils::Vector3d CoM() const
CoM Returns the position of the center of mass in the local reference frame.
std::shared_ptr< Mesh > m_mesh
Mesh of the segment.
utils::Scalar mass() const
Returns the segment mass.
void setCoM(const utils::Vector3d &com)
setCoM Change the position of the center of mass
void setMass(const utils::Scalar &newMass)
Set the new mass.
void setInertia(const utils::Matrix3d &inertia)
Set the matrix of inertia.
A wrapper for the Eigen::MatrixXd.
Definition Matrix3d.h:21
Wrapper around Eigen Vector3d and attach it to a parent.
Definition Vector3d.h:27