Main MRPT website > C++ reference for MRPT 1.9.9
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/poses/CPose3D.h>
11 #include <mrpt/poses/CPose3DQuat.h>
12 #include <mrpt/math/CQuaternion.h>
13 #include <iostream>
14 
15 using namespace mrpt;
16 using namespace mrpt::poses;
17 using namespace mrpt::math;
18 using namespace std;
19 
20 // ------------------------------------------------------
21 // TestQuaternions
22 // ------------------------------------------------------
23 void TestQuaternions()
24 {
25  CQuaternionDouble q1, q2, q3;
26 
27  // q1 = CQuaternionDouble(1,2,3,4); q1.normalize();
28  CPose3D p1(0, 0, 0, DEG2RAD(10), DEG2RAD(30), DEG2RAD(-20));
29  p1.getAsQuaternion(q1);
30 
31  CPose3D p2(0, 0, 0, DEG2RAD(30), DEG2RAD(-20), DEG2RAD(10));
32  p2.getAsQuaternion(q2);
33 
34  // q3 = q1 x q2
35  q3.crossProduct(q1, q2);
36 
37  const CPose3D p3 = p1 + p2;
38 
39  cout << "q1 = " << q1 << endl;
40  cout << "q1 as CPose3D = " << CPose3D(q1, 0, 0, 0) << endl;
41  cout << endl;
42  cout << "q2 = " << q2 << endl;
43  cout << "q2 as CPose3D = " << CPose3D(q2, 0, 0, 0) << endl;
44  cout << endl;
45  cout << "q3 = q1 * q2 = " << q3 << endl;
46  cout << "q3 as CPose3D = " << CPose3D(q3, 0, 0, 0) << endl;
47 
48  cout << endl << "Should be equal to p3 = p1 (+) p2 = " << p3 << endl;
49 }
50 
52 {
53  CPose3DQuat q(1.0, 2.0, 3.0, CQuaternionDouble());
54 
55  cout << "Dump with iterators: ";
56  for (CPose3DQuat::iterator it = q.begin(); it != q.end(); ++it)
57  cout << *it << " ";
58  cout << endl;
59 }
60 
61 int main(int argc, char** argv)
62 {
63  try
64  {
67 
68  return 0;
69  }
70  catch (std::exception& e)
71  {
72  std::cout << "MRPT exception caught: " << e.what() << std::endl;
73  return -1;
74  }
75  catch (...)
76  {
77  printf("Another exception!!");
78  return -1;
79  }
80 }
q
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
mrpt::poses::CPose3DQuat::iterator
Definition: CPose3DQuat.h:405
TestQuaternionsIterators
void TestQuaternionsIterators()
Definition: vision_stereo_rectify/test.cpp:51
CQuaternion.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::poses::CPose3DQuat
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
Definition: CPose3DQuat.h:48
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
TestQuaternions
void TestQuaternions()
Definition: vision_stereo_rectify/test.cpp:23
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
CPose3DQuat.h
mrpt::math::CQuaternion::crossProduct
void crossProduct(const CQuaternion &q1, const CQuaternion &q2)
Calculate the "cross" product (or "composed rotation") of two quaternion: this = q1 x q2 After the op...
Definition: CQuaternion.h:203
CPose3D.h
mrpt::math::CQuaternion
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ,...
Definition: CQuaternion.h:46
mrpt::math::CQuaternionDouble
CQuaternion< double > CQuaternionDouble
A quaternion of data type "double".
Definition: CQuaternion.h:504
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
mrpt::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: core/include/mrpt/core/bits_math.h:42



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST