Biorbd Release_1.13.0
Loading...
Searching...
No Matches
Vector2d.cpp
1#define BIORBD_API_EXPORTS
2#include "Utils/Vector2d.h"
3
4#include "Utils/RotoTrans.h"
5#include "Utils/Vector.h"
6
7using namespace BIORBD_NAMESPACE;
8
10 : RigidBodyDynamics::Math::Vector2d(
11 RigidBodyDynamics::Math::Vector2d::Zero()),
12 utils::Node() {
13 setType();
14}
15
16utils::Vector2d::Vector2d(const utils::Scalar &x, const utils::Scalar &y)
17 : RigidBodyDynamics::Math::Vector2d(x, y), utils::Node() {
18 setType();
19}
20
22 const utils::Scalar &x,
23 const utils::Scalar &y,
24 const utils::String &name,
25 const utils::String &parentName)
26 : RigidBodyDynamics::Math::Vector2d(x, y), utils::Node(name, parentName) {
27 setType();
28}
29
31 const utils::Vector2d vec,
32 const utils::String &name,
33 const utils::String &parentName)
34 : RigidBodyDynamics::Math::Vector2d(vec), Node(name, parentName) {}
35
36utils::Vector2d::Vector2d(const RigidBodyDynamics::Math::Vector2d &other)
37 : RigidBodyDynamics::Math::Vector2d(other[0], other[1]), utils::Node() {
38 setType();
39}
40
41utils::Vector2d::Vector2d(const RigidBodyDynamics::Math::VectorNd &other)
42 : RigidBodyDynamics::Math::Vector2d(other[0], other[1]), utils::Node() {
43 setType();
44}
45
46#ifdef BIORBD_USE_CASADI_MATH
47
48utils::Vector2d::Vector2d(const RBDLCasadiMath::MX_Xd_SubMatrix &other)
49 : RigidBodyDynamics::Math::Vector2d(other), utils::Node() {
50 setType();
51}
52
53#endif
54
56 utils::Vector2d copy;
57 copy.DeepCopy(*this);
58 return copy;
59}
60
62 this->RigidBodyDynamics::Math::Vector2d::operator=(other);
64}
65
67#ifdef BIORBD_USE_CASADI_MATH
68 (*this)(0) = v(0);
69 (*this)(1) = v(1);
70#else
71 *this = v;
72#endif
73}
74
75void utils::Vector2d::setType() { *m_typeOfNode = utils::VECTOR2D; }
76
77#ifdef BIORBD_USE_CASADI_MATH
78utils::Scalar utils::Vector2d::x() const { return (*this)[0]; }
79
80utils::Scalar utils::Vector2d::y() const { return (*this)[1]; }
81
82void utils::Vector2d::operator=(const RBDLCasadiMath::MX_Xd_SubMatrix &other) {
83 *this = utils::Vector2d(other);
84}
85
86#endif
A node is an abstract element which is assigned to a parent.
Definition Node.h:17
Node()
Construct Node.
Definition Node.cpp:8
const String & name() const
Return the name of the node.
Definition Node.cpp:43
std::shared_ptr< NODE_TYPE > m_typeOfNode
The type of the node.
Definition Node.h:92
void DeepCopy(const Node &other)
Deep copy of the node in another node.
Definition Node.cpp:35
Wrapper around the std::string class with augmented functionality.
Definition String.h:18
Wrapper around Eigen Vector2d and attach it to a parent.
Definition Vector2d.h:27
void setType()
Set the type Vector2d.
Definition Vector2d.cpp:75
void setPosition(const Vector2d &v)
Set a new position.
Definition Vector2d.cpp:66
Vector2d()
Construct 2D vector.
Definition Vector2d.cpp:9
Vector2d DeepCopy() const
Deep copy of a 2D vector.
Definition Vector2d.cpp:55