Biorbd
Release_1.13.0
Toggle main menu visibility
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
10
using namespace
BIORBD_NAMESPACE;
11
12
rigidbody::SegmentCharacteristics::SegmentCharacteristics
()
13
: Body(),
14
m_length
(std::make_shared<utils::Scalar>(0)),
15
m_mesh
(std::make_shared<rigidbody::
Mesh
>()) {}
16
rigidbody::SegmentCharacteristics::SegmentCharacteristics
(
17
const
utils::Scalar &
mass
,
18
const
utils::Vector3d
&com,
19
const
utils::Matrix3d
&
inertia
)
20
: Body(
mass
, com,
inertia
),
21
m_length
(std::make_shared<utils::Scalar>(0)),
22
m_mesh
(std::make_shared<rigidbody::
Mesh
>()) {}
23
rigidbody::SegmentCharacteristics::SegmentCharacteristics
(
24
const
utils::Scalar &
mass
,
25
const
utils::Vector3d
&com,
26
const
utils::Matrix3d
&
inertia
,
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
32
rigidbody::SegmentCharacteristics
rigidbody::SegmentCharacteristics::DeepCopy
()
33
const
{
34
rigidbody::SegmentCharacteristics
copy;
35
copy.
DeepCopy
(*
this
);
36
return
copy;
37
}
38
39
void
rigidbody::SegmentCharacteristics::DeepCopy
(
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
46
void
rigidbody::SegmentCharacteristics::setLength
(
const
utils::Scalar &val) {
47
*
m_length
= val;
48
}
49
50
utils::Scalar
rigidbody::SegmentCharacteristics::length
()
const
{
51
return
*
m_length
;
52
}
53
54
void
rigidbody::SegmentCharacteristics::setMass
(
const
utils::Scalar &newMass) {
55
mMass = newMass;
56
}
57
58
utils::Scalar
rigidbody::SegmentCharacteristics::mass
()
const
{
return
mMass; }
59
60
utils::Vector3d
rigidbody::SegmentCharacteristics::CoM
()
const
{
61
return
mCenterOfMass;
62
}
63
64
void
rigidbody::SegmentCharacteristics::setCoM
(
const
utils::Vector3d
&com) {
65
mCenterOfMass = com;
66
}
67
68
rigidbody::Mesh
&
rigidbody::SegmentCharacteristics::mesh
() {
return
*
m_mesh
; }
69
70
const
rigidbody::Mesh
&
rigidbody::SegmentCharacteristics::mesh
()
const
{
71
return
*
m_mesh
;
72
}
73
74
const
utils::Matrix3d
rigidbody::SegmentCharacteristics::inertia
()
const
{
75
return
mInertia;
76
}
77
78
void
rigidbody::SegmentCharacteristics::setInertia
(
79
const
utils::Matrix3d
&
inertia
) {
80
mInertia =
inertia
;
81
}
BIORBD_NAMESPACE::rigidbody::Mesh
A class that holds the geometry of a segment.
Definition
Mesh.h:22
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics
Characteristics of a segment, namely the mass, the center of mass, the inertia, the length and its me...
Definition
SegmentCharacteristics.h:30
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::setLength
void setLength(const utils::Scalar &val)
Set the segment length.
Definition
SegmentCharacteristics.cpp:46
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::mesh
Mesh & mesh()
Returns the segment mesh.
Definition
SegmentCharacteristics.cpp:68
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::SegmentCharacteristics
SegmentCharacteristics()
Construct segment characteristics.
Definition
SegmentCharacteristics.cpp:12
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::m_length
std::shared_ptr< utils::Scalar > m_length
Length of the segment.
Definition
SegmentCharacteristics.h:135
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::length
utils::Scalar length() const
Returns the segment length.
Definition
SegmentCharacteristics.cpp:50
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::inertia
const utils::Matrix3d inertia() const
Returns the segment inertia matrix.
Definition
SegmentCharacteristics.cpp:74
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::DeepCopy
SegmentCharacteristics DeepCopy() const
Deep copy of the segment characteristics.
Definition
SegmentCharacteristics.cpp:32
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::CoM
utils::Vector3d CoM() const
CoM Returns the position of the center of mass in the local reference frame.
Definition
SegmentCharacteristics.cpp:60
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::m_mesh
std::shared_ptr< Mesh > m_mesh
Mesh of the segment.
Definition
SegmentCharacteristics.h:136
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::mass
utils::Scalar mass() const
Returns the segment mass.
Definition
SegmentCharacteristics.cpp:58
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::setCoM
void setCoM(const utils::Vector3d &com)
setCoM Change the position of the center of mass
Definition
SegmentCharacteristics.cpp:64
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::setMass
void setMass(const utils::Scalar &newMass)
Set the new mass.
Definition
SegmentCharacteristics.cpp:54
BIORBD_NAMESPACE::rigidbody::SegmentCharacteristics::setInertia
void setInertia(const utils::Matrix3d &inertia)
Set the matrix of inertia.
Definition
SegmentCharacteristics.cpp:78
BIORBD_NAMESPACE::utils::Matrix3d
A wrapper for the Eigen::MatrixXd.
Definition
Matrix3d.h:21
BIORBD_NAMESPACE::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition
Vector3d.h:27
src
RigidBody
SegmentCharacteristics.cpp
Generated by
1.18.0