Biorbd
Vector3d.cpp
1 #define BIORBD_API_EXPORTS
2 #include "Utils/Vector3d.h"
3 
4 #include "Utils/RotoTrans.h"
5 #include "Utils/Vector.h"
6 
8  RigidBodyDynamics::Math::Vector3d (RigidBodyDynamics::Math::Vector3d::Zero()),
9  biorbd::utils::Node ()
10 {
11  setType();
12 }
13 
15  const biorbd::utils::Scalar& x,
16  const biorbd::utils::Scalar& y,
17  const biorbd::utils::Scalar& z) :
18  RigidBodyDynamics::Math::Vector3d (x, y, z),
19  biorbd::utils::Node ()
20 {
21  setType();
22 }
23 
25  const biorbd::utils::Scalar& x,
26  const biorbd::utils::Scalar& y,
27  const biorbd::utils::Scalar& z,
28  const biorbd::utils::String &name,
29  const biorbd::utils::String &parentName) :
30  RigidBodyDynamics::Math::Vector3d (x, y, z),
31  biorbd::utils::Node (name, parentName)
32 {
33  setType();
34 }
35 
37  const biorbd::utils::Vector3d vec,
38  const biorbd::utils::String &name,
39  const biorbd::utils::String &parentName) :
40  RigidBodyDynamics::Math::Vector3d (vec),
41  Node(name, parentName)
42 {
43 
44 }
45 
47  const RigidBodyDynamics::Math::Vector3d &other) :
48  RigidBodyDynamics::Math::Vector3d(other[0], other[1], other[2]), biorbd::utils::Node ()
49 {
50  setType();
51 }
52 
53 
55  const RigidBodyDynamics::Math::VectorNd &other) :
56  RigidBodyDynamics::Math::Vector3d(other[0], other[1], other[2]),
57  biorbd::utils::Node ()
58 {
59  setType();
60 }
61 
63  const RigidBodyDynamics::Math::Vector4d &other) :
64  RigidBodyDynamics::Math::Vector3d(other[0], other[1], other[2]), biorbd::utils::Node ()
65 {
66  setType();
67 }
68 
69 #ifdef BIORBD_USE_CASADI_MATH
70 
72  const RBDLCasadiMath::MX_Xd_SubMatrix &other) :
73  RigidBodyDynamics::Math::Vector3d(other),
74  biorbd::utils::Node ()
75 {
76  setType();
77 }
78 
79 #endif
80 
81 
83 {
85  copy.DeepCopy(*this);
86  return copy;
87 }
88 
90 {
91  this->RigidBodyDynamics::Math::Vector3d::operator=(other);
93 }
94 
96 {
97  RigidBodyDynamics::Math::Vector4d v;
98  v.block(0, 0, 3, 1) = *this;
99  v[3] = 1;
100  return static_cast<RigidBodyDynamics::Math::VectorNd>((rt * v).block(0, 0, 3, 1));
101 }
102 
104  RigidBodyDynamics::Math::Vector4d v;
105  v.block(0, 0, 3, 1) = *this;
106  v[3] = 1;
107  *this = (rt * v).block(0, 0, 3, 1);
108 }
109 
111 {
112  *m_typeOfNode = biorbd::utils::VECTOR3D;
113 }
114 
115 #ifdef BIORBD_USE_CASADI_MATH
116 biorbd::utils::Scalar biorbd::utils::Vector3d::x() const
117 {
118  return (*this)[0];
119 }
120 
121 biorbd::utils::Scalar biorbd::utils::Vector3d::y() const
122 {
123  return (*this)[1];
124 }
125 
126 biorbd::utils::Scalar biorbd::utils::Vector3d::z() const
127 {
128  return (*this)[2];
129 }
130 
131 void biorbd::utils::Vector3d::operator=(
132  const RBDLCasadiMath::MX_Xd_SubMatrix &other)
133 {
134  *this = biorbd::utils::Vector3d(other);
135 }
136 
137 void biorbd::utils::Vector3d::operator=(const RigidBodyDynamics::Math::Vector4d& other)
138 {
139  *this = biorbd::utils::Vector3d(other);
140 }
141 #endif
biorbd::utils::Vector3d
Wrapper around Eigen Vector3d and attach it to a parent.
Definition: Vector3d.h:24
biorbd::utils::Vector3d::DeepCopy
biorbd::utils::Vector3d DeepCopy() const
Deep copy of a 3D vector.
Definition: Vector3d.cpp:82
biorbd::utils::Node::DeepCopy
void DeepCopy(const biorbd::utils::Node &other)
Deep copy of the node in another node.
Definition: Node.cpp:46
biorbd::utils::Vector3d::applyRT
biorbd::utils::Vector3d applyRT(const RotoTrans &rt) const
Apply a RotoTrans to the 3D vector.
Definition: Vector3d.cpp:95
biorbd::utils::Node
A node is an abstract element which is assigned to a parent.
Definition: Node.h:16
biorbd::utils::RotoTrans
Homogenous matrix to describe translations and rotations simultaneously.
Definition: RotoTrans.h:34
biorbd::utils::Vector3d::Vector3d
Vector3d()
Construct 3D vector.
Definition: Vector3d.cpp:7
biorbd::utils::String
Wrapper around the std::string class with augmented functionality.
Definition: String.h:17
biorbd::utils::Vector3d::setType
void setType()
Set the type Vector3d.
Definition: Vector3d.cpp:110