40 #include <visp3/core/vpMatrix.h>
42 #ifdef ENABLE_VISP_NAMESPACE
49 std::cout <<
"Rotation vector size differ" << std::endl;
52 for (
unsigned int i = 0; i < a1.
getRows(); i++) {
53 for (
unsigned int j = 0; j < a1.
getCols(); j++) {
55 std::cout <<
"Array content differ" << std::endl;
66 std::cout <<
"Rotation vector size differ" << std::endl;
69 for (
unsigned int i = 0; i < a1.
size(); i++) {
71 std::cout <<
"Rotation vector content differ" << std::endl;
81 std::cout <<
"Column vector size differ" << std::endl;
84 for (
unsigned int i = 0; i < a1.
size(); i++) {
86 std::cout <<
"Column vector content differ" << std::endl;
96 std::cout <<
"Row vector size differ" << std::endl;
99 for (
unsigned int i = 0; i < a1.
size(); i++) {
101 std::cout <<
"Row vector content differ" << std::endl;
110 double epsilon = 1e-10;
112 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
115 std::cout <<
"a:\n" << a << std::endl;
116 a = { -1, -2, -3, 4, 5.5, 6.0f };
117 std::cout <<
"a:\n" << a << std::endl;
119 std::cout <<
"a.reshape(2,3):\n" << a << std::endl;
121 std::cout <<
"a.reshape(3,2):\n" << a << std::endl;
126 std::cout <<
"a2:\n" << a2 << std::endl;
129 std::cout <<
"a3:\n" << a3 << std::endl;
132 std::cout <<
"a4:\n" << a4 << std::endl;
135 a5 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
136 std::cout <<
"a5:\n" << a5 << std::endl;
139 std::cout <<
"a6:\n" << a6 << std::endl;
142 std::cout <<
"m:\n" << m << std::endl;
143 m = { -1, -2, -3, -4 };
144 std::cout <<
"m:\n" << m << std::endl;
146 std::cout <<
"m:\n" << m << std::endl;
148 vpMatrix m2(3, 2, { 1, 2, 3, 4, 5, 6 });
149 std::cout <<
"m2:\n" << m2 << std::endl;
151 vpMatrix m3 { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
152 std::cout <<
"m3:\n" << m3 << std::endl;
155 m4 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
156 std::cout <<
"m4:\n" << m4 << std::endl;
159 std::cout <<
"m5:\n" << m5 << std::endl;
170 std::cout <<
"m1:\n" << m1 << std::endl;
172 m1 << -1, -2, -3, -4;
174 std::cout <<
"m1:\n" << m1 << std::endl;
177 m2 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
178 std::cout <<
"m2:\n" << m2 << std::endl;
180 m2.resize(3, 3,
false);
181 std::cout <<
"m2:\n" << m2 << std::endl;
183 m2 << 0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11;
185 std::cout <<
"m2:\n" << m2 << std::endl;
189 std::cout <<
"** Test vpColVector" << std::endl;
191 for (
unsigned int i = 0; i < 6; i++) {
194 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
195 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
198 std::cout <<
"c: " << c.
t() << std::endl;
199 if (!equal(c_ref, c, epsilon)) {
204 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
206 std::cout <<
"c: " << c.t() << std::endl;
207 if (!equal(c_ref, c, epsilon)) {
213 std::cout <<
"c1: " << c1.t() << std::endl;
214 if (!equal(c_ref, c1, epsilon)) {
218 std::cout <<
"c1: " << c1.t() << std::endl;
222 std::cout <<
"c2: " << c2.
t() << std::endl;
223 if (!equal(c_ref, c2, epsilon)) {
231 std::cout <<
"c: " << c << std::endl;
235 std::cout <<
"after c.reshape(2, 2): " << c.
t() << std::endl;
237 std::cout <<
"c:" << c << std::endl;
240 std::cerr <<
"Exception expected: c = c.reshape(2, 2);\n" << e.
what() << std::endl;
243 std::cout <<
"c: " << c.
t() << std::endl;
246 std::cout <<
"ptr_array->reshape(2,2)" << std::endl;
247 std::cout <<
"c: (" << c.
getRows() <<
", " << c.
getCols() <<
"):\n" << c << std::endl;
248 std::cout <<
"dynamic_cast<vpColVector *>(ptr_array):\n" << *
dynamic_cast<vpColVector *
>(ptr_array) << std::endl;
249 std::cout <<
"ptr_array:\n" << *ptr_array << std::endl;
254 std::cout <<
"** Test vpRowVector" << std::endl;
256 for (
unsigned int i = 0; i < 6; i++) {
259 std::cout <<
"r_ref: " << r_ref << std::endl;
260 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
263 std::cout <<
"r: " << r << std::endl;
264 if (!equal(r_ref, r, epsilon)) {
269 std::cout <<
"r_ref: " << r_ref << std::endl;
271 std::cout <<
"r: " << r << std::endl;
272 if (!equal(r_ref, r, epsilon)) {
278 std::cout <<
"r1: " << r1 << std::endl;
279 if (!equal(r_ref, r1, epsilon)) {
283 std::cout <<
"r1: " << r1 << std::endl;
287 std::cout <<
"r2: " << r2 << std::endl;
288 if (!equal(r_ref, r2, epsilon)) {
296 std::cout <<
"r: " << r << std::endl;
299 std::cout <<
"m:\n" << m << std::endl;
303 std::cout <<
"after r.reshape(3, 1): " << r << std::endl;
306 std::cerr <<
"Exception: r.reshape(3, 1);\n" << e.
what() << std::endl;
312 std::cout <<
"** Test vpThetaUVector" << std::endl;
314 std::cout <<
"tu_ref: " << tu_ref.t() << std::endl;
315 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
318 std::cout <<
"tu: " << tu.
t() << std::endl;
319 if (!equal(tu_ref, tu, epsilon)) {
326 tu << 0, M_PI_2, M_PI;
327 std::cout <<
"tu: " << tu.
t() << std::endl;
328 if (!equal(tu_ref, tu, epsilon)) {
332 tu << 0, M_PI_2, M_PI;
333 std::cout <<
"tu: " << tu.
t() << std::endl;
334 if (!equal(tu_ref, tu, epsilon)) {
341 std::cout <<
"** Test vpRxyzVector" << std::endl;
343 std::cout <<
"rxyz_ref: " << rxyz_ref.t() << std::endl;
344 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
347 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
348 if (!equal(rxyz_ref, rxyz, epsilon)) {
355 rxyz << 0, M_PI_2, M_PI;
356 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
357 if (!equal(rxyz_ref, rxyz, epsilon)) {
361 rxyz << 0, M_PI_2, M_PI;
362 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
363 if (!equal(rxyz_ref, rxyz, epsilon)) {
370 std::cout <<
"** Test vpRzyxVector" << std::endl;
372 std::cout <<
"rzyx_ref: " << rzyx_ref.t() << std::endl;
373 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
376 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
377 if (!equal(rzyx_ref, rzyx, epsilon)) {
384 rzyx << 0, M_PI_2, M_PI;
385 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
386 if (!equal(rzyx_ref, rzyx, epsilon)) {
390 rzyx << 0, M_PI_2, M_PI;
391 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
392 if (!equal(rzyx_ref, rzyx, epsilon)) {
399 std::cout <<
"** Test vpRzyzVector" << std::endl;
401 std::cout <<
"rzyz_ref: " << rzyz_ref.t() << std::endl;
402 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
405 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
406 if (!equal(rzyz_ref, rzyz, epsilon)) {
413 rzyz << 0, M_PI_2, M_PI;
414 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
415 if (!equal(rzyz_ref, rzyz, epsilon)) {
419 rzyz << 0, M_PI_2, M_PI;
420 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
421 if (!equal(rzyz_ref, rzyz, epsilon)) {
428 std::cout <<
"** Test vpQuaternionVector" << std::endl;
431 std::cout <<
"q_ref: " << q_ref.t() << std::endl;
432 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
435 std::cout <<
"q: " << q.
t() << std::endl;
436 if (!equal(q_ref, q, epsilon)) {
443 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
444 std::cout <<
"q: " << q.
t() << std::endl;
445 if (!equal(q_ref, q, epsilon)) {
449 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
450 std::cout <<
"q: " << q.
t() << std::endl;
451 if (!equal(q_ref, q, epsilon)) {
458 std::cout <<
"** Test vpTranslationVector" << std::endl;
460 std::cout <<
"t_ref: " << t_ref.t() << std::endl;
461 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
464 std::cout <<
"t: " << t.
t() << std::endl;
465 if (!equal(t_ref, t, epsilon)) {
473 std::cout <<
"t: " << t.
t() << std::endl;
474 if (!equal(t_ref, t, epsilon)) {
479 std::cout <<
"t: " << t.
t() << std::endl;
480 if (!equal(t_ref, t, epsilon)) {
487 std::cout <<
"** Test vpRotationMatrix" << std::endl;
489 std::cout <<
"R_ref:\n" << R_ref << std::endl;
490 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
493 std::cout <<
"R:\n" << R << std::endl;
494 if (!equal(R_ref, R, epsilon)) {
500 R = { 0, 0, -1, 0, -1, 0, -1, 0, 0 };
501 std::cout <<
"R:\n" << R << std::endl;
502 if (!equal(R_ref, R, epsilon)) {
509 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
510 std::cout <<
"R:\n" << R << std::endl;
511 if (!equal(R_ref, R, epsilon)) {
515 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
516 std::cout <<
"R:\n" << R << std::endl;
517 if (!equal(R_ref, R, epsilon)) {
523 std::cout <<
"Test succeed" << std::endl;
unsigned int getCols() const
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
void reshape(unsigned int nrows, unsigned int ncols)
Implementation of column vector and the associated operations.
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
error that can be emitted by ViSP classes.
const char * what() const
static bool equal(double x, double y, double threshold=0.001)
Implementation of a matrix and operations on matrices.
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a generic rotation vector.
Implementation of row vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as Euler angle minimal representation.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.