42 #include <visp3/core/vpMatrix.h> 47 std::cout <<
"Rotation vector size differ" << std::endl;
50 for (
unsigned int i=0; i < a1.
getRows(); i++) {
51 for (
unsigned int j=0; j < a1.
getCols(); j++) {
53 std::cout <<
"Array content differ" << std::endl;
64 std::cout <<
"Rotation vector size differ" << std::endl;
67 for (
unsigned int i=0; i < a1.
size(); i++) {
69 std::cout <<
"Rotation vector content differ" << std::endl;
79 std::cout <<
"Column vector size differ" << std::endl;
82 for (
unsigned int i=0; i < a1.
size(); i++) {
84 std::cout <<
"Column vector content differ" << std::endl;
94 std::cout <<
"Row vector size differ" << std::endl;
97 for (
unsigned int i=0; i < a1.
size(); i++) {
99 std::cout <<
"Row vector content differ" << std::endl;
108 double epsilon = 1e-10;
109 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 112 std::cout <<
"a:\n" << a << std::endl;
113 a = { -1, -2, -3, 4, 5.5, 6.0f };
114 std::cout <<
"a:\n" << a << std::endl;
116 std::cout <<
"a.reshape(2,3):\n" << a << std::endl;
118 std::cout <<
"a.reshape(3,2):\n" << a << std::endl;
123 std::cout <<
"a2:\n" << a2 << std::endl;
126 std::cout <<
"a3:\n" << a3 << std::endl;
129 std::cout <<
"a4:\n" << a4 << std::endl;
132 a5 = { {1,2,3},{4,5,6},{7,8,9} };
133 std::cout <<
"a5:\n" << a5 << std::endl;
136 std::cout <<
"a6:\n" << a6 << std::endl;
139 std::cout <<
"m:\n" << m << std::endl;
140 m = { -1, -2, -3, -4 };
141 std::cout <<
"m:\n" << m << std::endl;
143 std::cout <<
"m:\n" << m << std::endl;
145 vpMatrix m2(3, 2, { 1, 2, 3, 4, 5, 6 });
146 std::cout <<
"m2:\n" << m2 << std::endl;
148 vpMatrix m3{ {1,2,3},{4,5,6},{7,8,9} };
149 std::cout <<
"m3:\n" << m3 << std::endl;
152 m4 = { {1,2,3},{4,5,6},{7,8,9} };
153 std::cout <<
"m4:\n" << m4 << std::endl;
156 std::cout <<
"m5:\n" << m5 << std::endl;
167 std::cout <<
"m1:\n" << m1 << std::endl;
169 m1 << -1, -2, -3, -4;
171 std::cout <<
"m1:\n" << m1 << std::endl;
174 m2 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
175 std::cout <<
"m2:\n" << m2 << std::endl;
177 m2.resize(3, 3,
false);
178 std::cout <<
"m2:\n" << m2 << std::endl;
180 m2 << 0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11;
182 std::cout <<
"m2:\n" << m2 << std::endl;
186 std::cout <<
"** Test vpColVector" << std::endl;
188 for (
unsigned int i=0; i < 6; i ++) {
191 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
192 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 195 std::cout <<
"c: " << c.
t() << std::endl;
196 if (! equal(c_ref, c, epsilon)) {
201 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
203 std::cout <<
"c: " << c.t() << std::endl;
204 if (! equal(c_ref, c, epsilon)) {
210 std::cout <<
"c1: " << c1.t() << std::endl;
211 if (! equal(c_ref, c1, epsilon)) {
215 std::cout <<
"c1: " << c1.t() << std::endl;
219 std::cout <<
"c2: " << c2.
t() << std::endl;
220 if (! equal(c_ref, c2, epsilon)) {
228 std::cout <<
"c: " << c << std::endl;
232 std::cout <<
"after c.reshape(2, 2): " << c.
t() << std::endl;
234 std::cout <<
"c:" << c << std::endl;
236 std::cerr <<
"Exception expected: c = c.reshape(2, 2);\n" << e.
what() << std::endl;
239 std::cout <<
"c: " << c.
t() << std::endl;
242 std::cout <<
"ptr_array->reshape(2,2)" << std::endl;
243 std::cout <<
"c: (" << c.
getRows() <<
", " << c.
getCols() <<
"):\n" << c << std::endl;
244 std::cout <<
"dynamic_cast<vpColVector *>(ptr_array):\n" << *
dynamic_cast<vpColVector *
>(ptr_array) << std::endl;
245 std::cout <<
"ptr_array:\n" << *ptr_array << std::endl;
250 std::cout <<
"** Test vpRowVector" << std::endl;
252 for (
unsigned int i=0; i < 6; i ++) {
255 std::cout <<
"r_ref: " << r_ref << std::endl;
256 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 259 std::cout <<
"r: " << r << std::endl;
260 if (! equal(r_ref, r, epsilon)) {
265 std::cout <<
"r_ref: " << r_ref << std::endl;
267 std::cout <<
"r: " << r << std::endl;
268 if (! equal(r_ref, r, epsilon)) {
274 std::cout <<
"r1: " << r1 << std::endl;
275 if (! equal(r_ref, r1, epsilon)) {
279 std::cout <<
"r1: " << r1 << std::endl;
283 std::cout <<
"r2: " << r2 << std::endl;
284 if (! equal(r_ref, r2, epsilon)) {
292 std::cout <<
"r: " << r << std::endl;
295 std::cout <<
"m:\n" << m << std::endl;
299 std::cout <<
"after r.reshape(3, 1): " << r << std::endl;
301 std::cerr <<
"Exception: r.reshape(3, 1);\n" << e.
what() << std::endl;
307 std::cout <<
"** Test vpThetaUVector" << std::endl;
309 std::cout <<
"tu_ref: " << tu_ref.t() << std::endl;
310 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 313 std::cout <<
"tu: " << tu.
t() << std::endl;
314 if (! equal(tu_ref, tu, epsilon)) {
321 tu << 0, M_PI_2, M_PI;
322 std::cout <<
"tu: " << tu.
t() << std::endl;
323 if (! equal(tu_ref, tu, epsilon)) {
327 tu << 0, M_PI_2, M_PI;
328 std::cout <<
"tu: " << tu.
t() << std::endl;
329 if (! equal(tu_ref, tu, epsilon)) {
336 std::cout <<
"** Test vpRxyzVector" << std::endl;
338 std::cout <<
"rxyz_ref: " << rxyz_ref.t() << std::endl;
339 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 342 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
343 if (! equal(rxyz_ref, rxyz, epsilon)) {
350 rxyz << 0, M_PI_2, M_PI;
351 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
352 if (! equal(rxyz_ref, rxyz, epsilon)) {
356 rxyz << 0, M_PI_2, M_PI;
357 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
358 if (! equal(rxyz_ref, rxyz, epsilon)) {
365 std::cout <<
"** Test vpRzyxVector" << std::endl;
367 std::cout <<
"rzyx_ref: " << rzyx_ref.t() << std::endl;
368 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 371 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
372 if (! equal(rzyx_ref, rzyx, epsilon)) {
379 rzyx << 0, M_PI_2, M_PI;
380 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
381 if (! equal(rzyx_ref, rzyx, epsilon)) {
385 rzyx << 0, M_PI_2, M_PI;
386 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
387 if (! equal(rzyx_ref, rzyx, epsilon)) {
394 std::cout <<
"** Test vpRzyzVector" << std::endl;
396 std::cout <<
"rzyz_ref: " << rzyz_ref.t() << std::endl;
397 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 400 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
401 if (! equal(rzyz_ref, rzyz, epsilon)) {
408 rzyz << 0, M_PI_2, M_PI;
409 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
410 if (! equal(rzyz_ref, rzyz, epsilon)) {
414 rzyz << 0, M_PI_2, M_PI;
415 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
416 if (! equal(rzyz_ref, rzyz, epsilon)) {
423 std::cout <<
"** Test vpQuaternionVector" << std::endl;
426 std::cout <<
"q_ref: " << q_ref.t() << std::endl;
427 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 430 std::cout <<
"q: " << q.
t() << std::endl;
431 if (! equal(q_ref, q, epsilon)) {
438 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
439 std::cout <<
"q: " << q.
t() << std::endl;
440 if (! equal(q_ref, q, epsilon)) {
444 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
445 std::cout <<
"q: " << q.
t() << std::endl;
446 if (! equal(q_ref, q, epsilon)) {
453 std::cout <<
"** Test vpTranslationVector" << std::endl;
455 std::cout <<
"t_ref: " << t_ref.t() << std::endl;
456 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 459 std::cout <<
"t: " << t.
t() << std::endl;
460 if (! equal(t_ref, t, epsilon)) {
468 std::cout <<
"t: " << t.
t() << std::endl;
469 if (! equal(t_ref, t, epsilon)) {
474 std::cout <<
"t: " << t.
t() << std::endl;
475 if (! equal(t_ref, t, epsilon)) {
482 std::cout <<
"** Test vpRotationMatrix" << std::endl;
484 std::cout <<
"R_ref:\n" << R_ref << std::endl;
485 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 488 std::cout <<
"R:\n" << R << std::endl;
489 if (! equal(R_ref, R, epsilon)) {
495 R = {0, 0, -1, 0, -1, 0, -1, 0, 0};
496 std::cout <<
"R:\n" << R << std::endl;
497 if (! equal(R_ref, R, epsilon)) {
504 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
505 std::cout <<
"R:\n" << R << std::endl;
506 if (! equal(R_ref, R, epsilon)) {
510 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
511 std::cout <<
"R:\n" << R << std::endl;
512 if (! equal(R_ref, R, epsilon)) {
518 std::cout <<
"Test succeed" << std::endl;
Implementation of a matrix and operations on matrices.
Implementation of a generic rotation vector.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Implementation of row vector and the associated operations.
static bool equal(double x, double y, double s=0.001)
error that can be emited by ViSP classes.
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getCols() const
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation matrix and operations on such kind of matrices.
const char * what() const
Implementation of a rotation vector as quaternion angle minimal representation.
unsigned int getRows() const
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
Implementation of column vector and the associated operations.
Implementation of a rotation vector as Euler angle minimal representation.
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
Implementation of a rotation vector as Euler angle minimal representation.
void resize(unsigned int i, bool flagNullify=true)
void reshape(unsigned int nrows, unsigned int ncols)
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.