NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DCM.hpp
Go to the documentation of this file.
1
28#pragma once
29
32#include "NumCpp/Linalg/det.hpp"
33#include "NumCpp/NdArray.hpp"
37
39{
40 //================================================================================
42 class DCM
43 {
44 public:
45 //============================================================================
46 // Method Description:
55 static NdArray<double> eulerAngles(double roll, double pitch, double yaw)
56 {
57 return Quaternion(roll, pitch, yaw).toDCM();
58 }
59
60 //============================================================================
61 // Method Description:
72
73 //============================================================================
74 // Method Description:
86
87 //============================================================================
88 // Method Description:
97 {
98 return Quaternion(inAxis, inAngle).toDCM();
99 }
100
101 //============================================================================
102 // Method Description:
109 static bool isValid(const NdArray<double>& inArray)
110 {
111 const Shape inShape = inArray.shape();
112 return inShape.rows == inShape.cols &&
113 utils::essentiallyEqual(round(linalg::det<double>(inArray), 2), 1.) &&
114 utils::essentiallyEqual(round(linalg::det<double>(inArray.transpose()), 2), 1.);
115 }
116
117 //============================================================================
118 // Method Description:
124 static double roll(const NdArray<double>& dcm)
125 {
126 return Quaternion(dcm).roll();
127 }
128
129 //============================================================================
130 // Method Description:
136 static double pitch(const NdArray<double>& dcm)
137 {
138 return Quaternion(dcm).pitch();
139 }
140
141 //============================================================================
142 // Method Description:
148 static double yaw(const NdArray<double>& dcm)
149 {
150 return Quaternion(dcm).yaw();
151 }
152
153 //============================================================================
154 // Method Description:
162 {
163 return DCM::eulerAxisAngle(Vec3{ 1., 0., 0. }, inAngle);
164 }
165
166 //============================================================================
167 // Method Description:
175 {
176 return DCM::eulerAxisAngle(Vec3{ 0., 1., 0. }, inAngle);
177 }
178
179 //============================================================================
180 // Method Description:
188 {
189 return DCM::eulerAxisAngle(Vec3{ 0., 0., 1. }, inAngle);
190 }
191 };
192} // namespace nc::rotations
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
uint32 rows
Definition Core/shape.hpp:44
Holds a 3D vector.
Definition Vec3.hpp:51
Factory methods for generating direction cosine matrices and vectors.
Definition DCM.hpp:43
static NdArray< double > eulerAngles(const NdArray< double > &angles)
Definition DCM.hpp:68
static NdArray< double > eulerAxisAngle(const Vec3 &inAxis, double inAngle)
Definition DCM.hpp:96
static NdArray< double > yRotation(double inAngle)
Definition DCM.hpp:174
static NdArray< double > xRotation(double inAngle)
Definition DCM.hpp:161
static NdArray< double > zRotation(double inAngle)
Definition DCM.hpp:187
static double pitch(const NdArray< double > &dcm)
Definition DCM.hpp:136
static bool isValid(const NdArray< double > &inArray)
Definition DCM.hpp:109
static NdArray< double > eulerAxisAngle(const NdArray< double > &inAxis, double inAngle)
Definition DCM.hpp:82
static double roll(const NdArray< double > &dcm)
Definition DCM.hpp:124
static double yaw(const NdArray< double > &dcm)
Definition DCM.hpp:148
static NdArray< double > eulerAngles(double roll, double pitch, double yaw)
Definition DCM.hpp:55
Holds a unit quaternion.
Definition Quaternion.hpp:56
double roll() const noexcept
Definition Quaternion.hpp:402
double yaw() const noexcept
Definition Quaternion.hpp:607
double pitch() const noexcept
Definition Quaternion.hpp:370
NdArray< double > toDCM() const
Definition Quaternion.hpp:549
Definition DCM.hpp:39
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition essentiallyEqual.hpp:49
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
dtype round(dtype inValue, uint8 inDecimals=0)
Definition round.hpp:45