NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
Orientation.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <iostream>
31
32#include "NumCpp/NdArray.hpp"
34
35namespace nc::coordinates
36{
41 {
42 public:
43 double roll{ 0. };
44 double pitch{ 0. };
45 double yaw{ 0. };
46
50 Orientation() noexcept = default;
51
59 constexpr Orientation(double inRoll, double inPitch, double inYaw) noexcept :
60 roll(inRoll),
61 pitch(inPitch),
62 yaw(inYaw)
63 {
64 }
65
71 Orientation(const Orientation& other) noexcept = default;
72
78 Orientation(Orientation&& other) noexcept = default;
79
83 virtual ~Orientation() = default;
84
89 [[nodiscard]] NdArray<double> toNdArray() const
90 {
91 NdArray<double> returnArray = { roll, pitch, yaw };
92 return returnArray.transpose();
93 }
94
100 Orientation& operator=(const Orientation& other) noexcept = default;
101
107 Orientation& operator=(Orientation&& other) noexcept = default;
108
115 bool operator==(const Orientation& other) const noexcept
116 {
117 return utils::essentiallyEqual(roll, other.roll) && utils::essentiallyEqual(pitch, other.pitch) &&
118 utils::essentiallyEqual(yaw, other.yaw);
119 }
120
127 bool operator!=(const Orientation& other) const noexcept
128 {
129 return !(*this == other);
130 }
131 };
132
139 inline std::ostream& operator<<(std::ostream& os, const Orientation& orientation)
140 {
141 os << "Orientation(roll=" << orientation.roll << ", pitch=" << orientation.pitch << ", yaw=" << orientation.yaw
142 << ")\n";
143 return os;
144 }
145} // namespace nc::coordinates
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
self_type transpose() const
Definition NdArrayCore.hpp:4959
Orientation.
Definition Orientation.hpp:41
Orientation() noexcept=default
Default Constructor.
Orientation & operator=(Orientation &&other) noexcept=default
Move Assignement Operator.
bool operator!=(const Orientation &other) const noexcept
Non-Equality Operator.
Definition Orientation.hpp:127
Orientation(const Orientation &other) noexcept=default
Copy Constructor.
Orientation & operator=(const Orientation &other) noexcept=default
Copy Assignement Operator.
double roll
Definition Orientation.hpp:43
NdArray< double > toNdArray() const
Convert to NdArray.
Definition Orientation.hpp:89
virtual ~Orientation()=default
Destructor.
Orientation(Orientation &&other) noexcept=default
Move Orientation.
bool operator==(const Orientation &other) const noexcept
Non-Equality Operator.
Definition Orientation.hpp:115
double pitch
Definition Orientation.hpp:44
double yaw
Definition Orientation.hpp:45
Definition Cartesian.hpp:39
std::ostream & operator<<(std::ostream &os, const Cartesian &vec)
Stream operator.
Definition Cartesian.hpp:296
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition essentiallyEqual.hpp:47