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;
110 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
113 std::cout <<
"a:\n" << a << std::endl;
114 a = { -1, -2, -3, 4, 5.5, 6.0f };
115 std::cout <<
"a:\n" << a << std::endl;
117 std::cout <<
"a.reshape(2,3):\n" << a << std::endl;
119 std::cout <<
"a.reshape(3,2):\n" << a << std::endl;
124 std::cout <<
"a2:\n" << a2 << std::endl;
127 std::cout <<
"a3:\n" << a3 << std::endl;
130 std::cout <<
"a4:\n" << a4 << std::endl;
133 a5 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
134 std::cout <<
"a5:\n" << a5 << std::endl;
137 std::cout <<
"a6:\n" << a6 << std::endl;
140 std::cout <<
"m:\n" << m << std::endl;
141 m = { -1, -2, -3, -4 };
142 std::cout <<
"m:\n" << m << std::endl;
144 std::cout <<
"m:\n" << m << std::endl;
146 vpMatrix m2(3, 2, { 1, 2, 3, 4, 5, 6 });
147 std::cout <<
"m2:\n" << m2 << std::endl;
149 vpMatrix m3 { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
150 std::cout <<
"m3:\n" << m3 << std::endl;
153 m4 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
154 std::cout <<
"m4:\n" << m4 << std::endl;
157 std::cout <<
"m5:\n" << m5 << std::endl;
168 std::cout <<
"m1:\n" << m1 << std::endl;
170 m1 << -1, -2, -3, -4;
172 std::cout <<
"m1:\n" << m1 << std::endl;
175 m2 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
176 std::cout <<
"m2:\n" << m2 << std::endl;
178 m2.resize(3, 3,
false);
179 std::cout <<
"m2:\n" << m2 << std::endl;
181 m2 << 0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11;
183 std::cout <<
"m2:\n" << m2 << std::endl;
187 std::cout <<
"** Test vpColVector" << std::endl;
189 for (
unsigned int i = 0; i < 6; i++) {
192 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
193 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
196 std::cout <<
"c: " << c.
t() << std::endl;
197 if (!equal(c_ref, c, epsilon)) {
202 std::cout <<
"c_ref: " << c_ref.t() << std::endl;
204 std::cout <<
"c: " << c.t() << std::endl;
205 if (!equal(c_ref, c, epsilon)) {
211 std::cout <<
"c1: " << c1.t() << std::endl;
212 if (!equal(c_ref, c1, epsilon)) {
216 std::cout <<
"c1: " << c1.t() << std::endl;
220 std::cout <<
"c2: " << c2.
t() << std::endl;
221 if (!equal(c_ref, c2, epsilon)) {
229 std::cout <<
"c: " << c << std::endl;
233 std::cout <<
"after c.reshape(2, 2): " << c.
t() << std::endl;
235 std::cout <<
"c:" << c << std::endl;
238 std::cerr <<
"Exception expected: c = c.reshape(2, 2);\n" << e.
what() << std::endl;
241 std::cout <<
"c: " << c.
t() << std::endl;
244 std::cout <<
"ptr_array->reshape(2,2)" << std::endl;
245 std::cout <<
"c: (" << c.
getRows() <<
", " << c.
getCols() <<
"):\n" << c << std::endl;
246 std::cout <<
"dynamic_cast<vpColVector *>(ptr_array):\n" << *
dynamic_cast<vpColVector *
>(ptr_array) << std::endl;
247 std::cout <<
"ptr_array:\n" << *ptr_array << std::endl;
252 std::cout <<
"** Test vpRowVector" << std::endl;
254 for (
unsigned int i = 0; i < 6; i++) {
257 std::cout <<
"r_ref: " << r_ref << std::endl;
258 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
261 std::cout <<
"r: " << r << std::endl;
262 if (!equal(r_ref, r, epsilon)) {
267 std::cout <<
"r_ref: " << r_ref << std::endl;
269 std::cout <<
"r: " << r << std::endl;
270 if (!equal(r_ref, r, epsilon)) {
276 std::cout <<
"r1: " << r1 << std::endl;
277 if (!equal(r_ref, r1, epsilon)) {
281 std::cout <<
"r1: " << r1 << std::endl;
285 std::cout <<
"r2: " << r2 << std::endl;
286 if (!equal(r_ref, r2, epsilon)) {
294 std::cout <<
"r: " << r << std::endl;
297 std::cout <<
"m:\n" << m << std::endl;
301 std::cout <<
"after r.reshape(3, 1): " << r << std::endl;
304 std::cerr <<
"Exception: r.reshape(3, 1);\n" << e.
what() << std::endl;
310 std::cout <<
"** Test vpThetaUVector" << std::endl;
312 std::cout <<
"tu_ref: " << tu_ref.t() << std::endl;
313 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
316 std::cout <<
"tu: " << tu.
t() << std::endl;
317 if (!equal(tu_ref, tu, epsilon)) {
324 tu << 0, M_PI_2, M_PI;
325 std::cout <<
"tu: " << tu.
t() << std::endl;
326 if (!equal(tu_ref, tu, epsilon)) {
330 tu << 0, M_PI_2, M_PI;
331 std::cout <<
"tu: " << tu.
t() << std::endl;
332 if (!equal(tu_ref, tu, epsilon)) {
339 std::cout <<
"** Test vpRxyzVector" << std::endl;
341 std::cout <<
"rxyz_ref: " << rxyz_ref.t() << std::endl;
342 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
345 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
346 if (!equal(rxyz_ref, rxyz, epsilon)) {
353 rxyz << 0, M_PI_2, M_PI;
354 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
355 if (!equal(rxyz_ref, rxyz, epsilon)) {
359 rxyz << 0, M_PI_2, M_PI;
360 std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
361 if (!equal(rxyz_ref, rxyz, epsilon)) {
368 std::cout <<
"** Test vpRzyxVector" << std::endl;
370 std::cout <<
"rzyx_ref: " << rzyx_ref.t() << std::endl;
371 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
374 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
375 if (!equal(rzyx_ref, rzyx, epsilon)) {
382 rzyx << 0, M_PI_2, M_PI;
383 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
384 if (!equal(rzyx_ref, rzyx, epsilon)) {
388 rzyx << 0, M_PI_2, M_PI;
389 std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
390 if (!equal(rzyx_ref, rzyx, epsilon)) {
397 std::cout <<
"** Test vpRzyzVector" << std::endl;
399 std::cout <<
"rzyz_ref: " << rzyz_ref.t() << std::endl;
400 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
403 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
404 if (!equal(rzyz_ref, rzyz, epsilon)) {
411 rzyz << 0, M_PI_2, M_PI;
412 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
413 if (!equal(rzyz_ref, rzyz, epsilon)) {
417 rzyz << 0, M_PI_2, M_PI;
418 std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
419 if (!equal(rzyz_ref, rzyz, epsilon)) {
426 std::cout <<
"** Test vpQuaternionVector" << std::endl;
429 std::cout <<
"q_ref: " << q_ref.t() << std::endl;
430 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
433 std::cout <<
"q: " << q.
t() << std::endl;
434 if (!equal(q_ref, q, epsilon)) {
441 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
442 std::cout <<
"q: " << q.
t() << std::endl;
443 if (!equal(q_ref, q, epsilon)) {
447 q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
448 std::cout <<
"q: " << q.
t() << std::endl;
449 if (!equal(q_ref, q, epsilon)) {
456 std::cout <<
"** Test vpTranslationVector" << std::endl;
458 std::cout <<
"t_ref: " << t_ref.t() << std::endl;
459 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
462 std::cout <<
"t: " << t.
t() << std::endl;
463 if (!equal(t_ref, t, epsilon)) {
471 std::cout <<
"t: " << t.
t() << std::endl;
472 if (!equal(t_ref, t, epsilon)) {
477 std::cout <<
"t: " << t.
t() << std::endl;
478 if (!equal(t_ref, t, epsilon)) {
485 std::cout <<
"** Test vpRotationMatrix" << std::endl;
487 std::cout <<
"R_ref:\n" << R_ref << std::endl;
488 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
491 std::cout <<
"R:\n" << R << std::endl;
492 if (!equal(R_ref, R, epsilon)) {
498 R = { 0, 0, -1, 0, -1, 0, -1, 0, 0 };
499 std::cout <<
"R:\n" << R << std::endl;
500 if (!equal(R_ref, R, epsilon)) {
507 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
508 std::cout <<
"R:\n" << R << std::endl;
509 if (!equal(R_ref, R, epsilon)) {
513 R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
514 std::cout <<
"R:\n" << R << std::endl;
515 if (!equal(R_ref, R, epsilon)) {
521 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.