NVIDIA DeepStream SDK API Reference

6.4 Release
MathTypes.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 
11 #ifndef CVCORE_Math_H
12 #define CVCORE_Math_H
13 
14 #include <algorithm>
15 #include <cassert>
16 #include <cmath>
17 #include <vector>
18 
19 #include "Tensor.h"
20 
21 namespace cvcore {
22 
26 
31 template<class T>
32 struct Vector2
33 {
34  T x;
35  T y;
37  inline T &operator[](size_t i)
38  {
39  if (i == 0)
40  {
41  return x;
42  }
43  else if (i == 1)
44  {
45  return y;
46  }
47  else
48  {
49  throw std::out_of_range("cvcore::Vector2 ==> Requested index is out of bounds");
50  }
51  }
52 };
53 
58 template<class T>
59 struct Vector3
60 {
61  T x;
62  T y;
63  T z;
65  inline T &operator[](size_t i)
66  {
67  if (i == 0)
68  {
69  return x;
70  }
71  else if (i == 1)
72  {
73  return y;
74  }
75  else if (i == 2)
76  {
77  return z;
78  }
79  else
80  {
81  throw std::out_of_range("cvcore::Vector3 ==> Requested index is out of bounds");
82  }
83  }
84 };
85 
88 
91 
94 
100 {
101  double angle;
105  : angle(0.0)
106  , axis{0, 0, 0}
107  {
108  }
109 
110  AxisAngleRotation(double angleinput, Vector3d axisinput)
111  : angle(angleinput)
112  , axis(axisinput)
113  {
114  }
115 };
116 
124 {
125  double qx, qy, qz;
126  double qw;
129  : qx(0.0)
130  , qy(0.0)
131  , qz(0.0)
132  , qw(0.0)
133  {
134  }
135 
136  Quaternion(double qxinput, double qyinput, double qzinput, double qwinput)
137  : qx(qxinput)
138  , qy(qyinput)
139  , qz(qzinput)
140  , qw(qwinput)
141  {
142  }
143 };
144 
151 Vector3d RotationMatrixToRotationVector(const std::vector<double> &rotMatrix);
152 
158 AxisAngleRotation RotationMatrixToAxisAngleRotation(const std::vector<double> &rotMatrix);
159 
165 std::vector<double> AxisAngleToRotationMatrix(const AxisAngleRotation &axisangle);
166 
174 Vector3d AxisAngleRotationToRotationVector(const AxisAngleRotation &axisangle);
175 
181 AxisAngleRotation RotationVectorToAxisAngleRotation(const Vector3d &rotVector);
182 
188 Quaternion AxisAngleRotationToQuaternion(const AxisAngleRotation &axisangle);
189 
195 AxisAngleRotation QuaternionToAxisAngleRotation(const Quaternion &qrotation);
196 
202 std::vector<double> QuaternionToRotationMatrix(const Quaternion &qrotation);
203 
209 Quaternion RotationMatrixToQuaternion(const std::vector<double> &rotMatrix);
210 
215 template<class T>
216 struct Pose3
217 {
219  Vector3<T> translation; /*Translation expressed as x,y,z coordinates.*/
220 };
221 
224 
225 } // namespace cvcore
226 
227 #endif // CVCORE_Math_H
cvcore::Vector2
A struct.
Definition: MathTypes.h:32
cvcore::Quaternion::qy
double qy
Definition: MathTypes.h:125
cvcore::Pose3::rotation
AxisAngleRotation rotation
Definition: MathTypes.h:218
cvcore
Definition: PnP.h:20
cvcore::RotationVectorToAxisAngleRotation
AxisAngleRotation RotationVectorToAxisAngleRotation(const Vector3d &rotVector)
Convert rotation vector to axis angle representation.
cvcore::Pose3::translation
Vector3< T > translation
Rotation expressed in axis angle notation.
Definition: MathTypes.h:219
cvcore::Quaternion::qz
double qz
Definition: MathTypes.h:125
cvcore::AxisAngleToRotationMatrix
std::vector< double > AxisAngleToRotationMatrix(const AxisAngleRotation &axisangle)
Convert axis angle representation to rotation matrix.
cvcore::RotationMatrixToRotationVector
Vector3d RotationMatrixToRotationVector(const std::vector< double > &rotMatrix)
Convert rotation matrix to rotation vector.
cvcore::Vector3
A struct.
Definition: MathTypes.h:59
cvcore::Quaternion::Quaternion
Quaternion(double qxinput, double qyinput, double qzinput, double qwinput)
Definition: MathTypes.h:136
cvcore::AxisAngleRotation
A struct Structure used to store AxisAngle Rotation parameters.
Definition: MathTypes.h:99
cvcore::Quaternion::qx
double qx
Definition: MathTypes.h:125
cvcore::Quaternion::Quaternion
Quaternion()
Angle or real component of the quaternion representation.
Definition: MathTypes.h:128
cvcore::QuaternionToAxisAngleRotation
AxisAngleRotation QuaternionToAxisAngleRotation(const Quaternion &qrotation)
Convert quaternion rotation to axis angle rotation.
cvcore::Vector3::operator[]
T & operator[](size_t i)
Definition: MathTypes.h:65
cvcore::QuaternionToRotationMatrix
std::vector< double > QuaternionToRotationMatrix(const Quaternion &qrotation)
Convert quaternion rotation to rotation matrix.
cvcore::Quaternion
A struct.
Definition: MathTypes.h:123
cvcore::AxisAngleRotationToRotationVector
Vector3d AxisAngleRotationToRotationVector(const AxisAngleRotation &axisangle)
Convert axis angle representation to 3d rotation vector.
cvcore::Tensor
Definition: Tensor.h:704
cvcore::Vector3::z
T z
point z coordinate.
Definition: MathTypes.h:63
cvcore::Vector2::x
T x
point x coordinate.
Definition: MathTypes.h:34
cvcore::Quaternion::qw
double qw
Axis or imaginary component of the quaternion representation.
Definition: MathTypes.h:126
cvcore::RotationMatrixToQuaternion
Quaternion RotationMatrixToQuaternion(const std::vector< double > &rotMatrix)
Convert rotation matrix to Quaternion.
cvcore::AxisAngleRotation::AxisAngleRotation
AxisAngleRotation()
3d axis of rotation.
Definition: MathTypes.h:104
cvcore::Vector2::y
T y
point y coordinate.
Definition: MathTypes.h:35
cvcore::AxisAngleRotation::angle
double angle
Definition: MathTypes.h:101
cvcore::Pose3
A struct.
Definition: MathTypes.h:216
cvcore::Vector3d
Vector3< double > Vector3d
Definition: MathTypes.h:93
cvcore::AxisAngleRotation::AxisAngleRotation
AxisAngleRotation(double angleinput, Vector3d axisinput)
Definition: MathTypes.h:110
cvcore::Vector3::y
T y
point y coordinate.
Definition: MathTypes.h:62
Tensor.h
cvcore::RotationMatrixToAxisAngleRotation
AxisAngleRotation RotationMatrixToAxisAngleRotation(const std::vector< double > &rotMatrix)
Convert rotation matrix to axis angle representation.
cvcore::AxisAngleRotationToQuaternion
Quaternion AxisAngleRotationToQuaternion(const AxisAngleRotation &axisangle)
Convert axis angle representation to quaternion.
cvcore::Vector2::operator[]
T & operator[](size_t i)
Definition: MathTypes.h:37
cvcore::Vector3::x
T x
point x coordinate.
Definition: MathTypes.h:61
cvcore::AxisAngleRotation::axis
Vector3d axis
Counterclockwise rotation angle [0, 2PI].
Definition: MathTypes.h:102