#include <visp3/core/vpMatrix.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
{
std::cout << "Rotation vector size differ" << std::endl;
return false;
}
for (
unsigned int i = 0; i < a1.
getRows(); i++) {
for (
unsigned int j = 0; j < a1.
getCols(); j++) {
std::cout << "Array content differ" << std::endl;
return false;
}
}
}
return true;
}
{
std::cout << "Rotation vector size differ" << std::endl;
return false;
}
for (
unsigned int i = 0; i < a1.
size(); i++) {
std::cout << "Rotation vector content differ" << std::endl;
return false;
}
}
return true;
}
{
std::cout << "Column vector size differ" << std::endl;
return false;
}
for (
unsigned int i = 0; i < a1.
size(); i++) {
std::cout << "Column vector content differ" << std::endl;
return false;
}
}
return true;
}
{
std::cout << "Row vector size differ" << std::endl;
return false;
}
for (
unsigned int i = 0; i < a1.
size(); i++) {
std::cout << "Row vector content differ" << std::endl;
return false;
}
}
return true;
}
int main()
{
double epsilon = 1e-10;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout << "a:\n" << a << std::endl;
a = { -1, -2, -3, 4, 5.5, 6.0f };
std::cout << "a:\n" << a << std::endl;
std::cout << "a.reshape(2,3):\n" << a << std::endl;
a.reshape(3, 2);
std::cout << "a.reshape(3,2):\n" << a << std::endl;
a2 = { 1, 2, 3, 4 };
std::cout << "a2:\n" << a2 << std::endl;
std::cout << "a3:\n" << a3 << std::endl;
std::cout << "a4:\n" << a4 << std::endl;
a5 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
std::cout << "a5:\n" << a5 << std::endl;
std::cout << "a6:\n" << a6 << std::endl;
std::cout << "m:\n" << m << std::endl;
m = { -1, -2, -3, -4 };
std::cout << "m:\n" << m << std::endl;
std::cout << "m:\n" << m << std::endl;
vpMatrix m2(3, 2, { 1, 2, 3, 4, 5, 6 });
std::cout << "m2:\n" << m2 << std::endl;
vpMatrix m3 { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
std::cout << "m3:\n" << m3 << std::endl;
m4 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
std::cout << "m4:\n" << m4 << std::endl;
std::cout << "m5:\n" << m5 << std::endl;
}
#endif
{
m1 << 1, 2, 3;
std::cout << "m1:\n" << m1 << std::endl;
m1 << -1, -2, -3, -4;
std::cout << "m1:\n" << m1 << std::endl;
m2 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
std::cout << "m2:\n" << m2 << std::endl;
m2.resize(3, 3, false);
std::cout << "m2:\n" << m2 << std::endl;
m2 << 0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11;
m2.reshape(2, 6);
std::cout << "m2:\n" << m2 << std::endl;
}
{
std::cout << "** Test vpColVector" << std::endl;
for (unsigned int i = 0; i < 6; i++) {
c_ref[i] = i;
}
std::cout << "c_ref: " << c_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"c: " << c.
t() << std::endl;
if (!equal(c_ref, c, epsilon)) {
return EXIT_FAILURE;
}
c_ref *= -1;
std::cout << "c_ref: " << c_ref.t() << std::endl;
c = { 0, -1, -2 };
std::cout << "c: " << c.t() << std::endl;
if (!equal(c_ref, c, epsilon)) {
return EXIT_FAILURE;
}
std::cout << "c1: " << c1.t() << std::endl;
if (!equal(c_ref, c1, epsilon)) {
return EXIT_FAILURE;
}
std::cout << "c1: " << c1.t() << std::endl;
if (c1.size()) {
return EXIT_FAILURE;
}
std::cout <<
"c2: " << c2.
t() << std::endl;
if (!equal(c_ref, c2, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
c << 1, 2, 3, 4;
std::cout << "c: " << c << std::endl;
try {
std::cout <<
"after c.reshape(2, 2): " << c.
t() << std::endl;
std::cout << "c:" << c << std::endl;
}
std::cerr <<
"Exception expected: c = c.reshape(2, 2);\n" << e.
what() << std::endl;
}
std::cout <<
"c: " << c.
t() << std::endl;
std::cout << "ptr_array->reshape(2,2)" << std::endl;
std::cout <<
"c: (" << c.
getRows() <<
", " << c.
getCols() <<
"):\n" << c << std::endl;
std::cout <<
"dynamic_cast<vpColVector *>(ptr_array):\n" << *
dynamic_cast<vpColVector *
>(ptr_array) << std::endl;
std::cout << "ptr_array:\n" << *ptr_array << std::endl;
}
}
{
std::cout << "** Test vpRowVector" << std::endl;
for (unsigned int i = 0; i < 6; i++) {
r_ref[i] = i;
}
std::cout << "r_ref: " << r_ref << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout << "r: " << r << std::endl;
if (!equal(r_ref, r, epsilon)) {
return EXIT_FAILURE;
}
r_ref *= -1;
std::cout << "r_ref: " << r_ref << std::endl;
r = { 0, -1, -2 };
std::cout << "r: " << r << std::endl;
if (!equal(r_ref, r, epsilon)) {
return EXIT_FAILURE;
}
std::cout << "r1: " << r1 << std::endl;
if (!equal(r_ref, r1, epsilon)) {
return EXIT_FAILURE;
}
std::cout << "r1: " << r1 << std::endl;
if (r1.size()) {
return EXIT_FAILURE;
}
std::cout << "r2: " << r2 << std::endl;
if (!equal(r_ref, r2, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
r << 1, 2, 3;
std::cout << "r: " << r << std::endl;
std::cout << "m:\n" << m << std::endl;
try {
std::cout << "after r.reshape(3, 1): " << r << std::endl;
}
std::cerr <<
"Exception: r.reshape(3, 1);\n" << e.
what() << std::endl;
}
}
}
{
std::cout << "** Test vpThetaUVector" << std::endl;
std::cout << "tu_ref: " << tu_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"tu: " << tu.
t() << std::endl;
if (!equal(tu_ref, tu, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
tu << 0, M_PI_2, M_PI;
std::cout <<
"tu: " << tu.
t() << std::endl;
if (!equal(tu_ref, tu, epsilon)) {
return EXIT_FAILURE;
}
tu << 0, M_PI_2, M_PI;
std::cout <<
"tu: " << tu.
t() << std::endl;
if (!equal(tu_ref, tu, epsilon)) {
return EXIT_FAILURE;
}
}
}
{
std::cout << "** Test vpRxyzVector" << std::endl;
std::cout << "rxyz_ref: " << rxyz_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
if (!equal(rxyz_ref, rxyz, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
rxyz << 0, M_PI_2, M_PI;
std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
if (!equal(rxyz_ref, rxyz, epsilon)) {
return EXIT_FAILURE;
}
rxyz << 0, M_PI_2, M_PI;
std::cout <<
"rxyz: " << rxyz.
t() << std::endl;
if (!equal(rxyz_ref, rxyz, epsilon)) {
return EXIT_FAILURE;
}
}
}
{
std::cout << "** Test vpRzyxVector" << std::endl;
std::cout << "rzyx_ref: " << rzyx_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
if (!equal(rzyx_ref, rzyx, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
rzyx << 0, M_PI_2, M_PI;
std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
if (!equal(rzyx_ref, rzyx, epsilon)) {
return EXIT_FAILURE;
}
rzyx << 0, M_PI_2, M_PI;
std::cout <<
"rzyx: " << rzyx.
t() << std::endl;
if (!equal(rzyx_ref, rzyx, epsilon)) {
return EXIT_FAILURE;
}
}
}
{
std::cout << "** Test vpRzyzVector" << std::endl;
std::cout << "rzyz_ref: " << rzyz_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
if (!equal(rzyz_ref, rzyz, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
rzyz << 0, M_PI_2, M_PI;
std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
if (!equal(rzyz_ref, rzyz, epsilon)) {
return EXIT_FAILURE;
}
rzyz << 0, M_PI_2, M_PI;
std::cout <<
"rzyz: " << rzyz.
t() << std::endl;
if (!equal(rzyz_ref, rzyz, epsilon)) {
return EXIT_FAILURE;
}
}
}
{
std::cout << "** Test vpQuaternionVector" << std::endl;
std::cout << "q_ref: " << q_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"q: " << q.
t() << std::endl;
if (!equal(q_ref, q, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
std::cout <<
"q: " << q.
t() << std::endl;
if (!equal(q_ref, q, epsilon)) {
return EXIT_FAILURE;
}
q << q_ref[0], q_ref[1], q_ref[2], q_ref[3];
std::cout <<
"q: " << q.
t() << std::endl;
if (!equal(q_ref, q, epsilon)) {
return EXIT_FAILURE;
}
}
}
{
std::cout << "** Test vpTranslationVector" << std::endl;
std::cout << "t_ref: " << t_ref.t() << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout <<
"t: " << t.
t() << std::endl;
if (!equal(t_ref, t, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
t << 0, 0.1, 0.5;
std::cout <<
"t: " << t.
t() << std::endl;
if (!equal(t_ref, t, epsilon)) {
return EXIT_FAILURE;
}
t << 0, 0.1, 0.5;
std::cout <<
"t: " << t.
t() << std::endl;
if (!equal(t_ref, t, epsilon)) {
return EXIT_FAILURE;
}
}
}
{
std::cout << "** Test vpRotationMatrix" << std::endl;
std::cout << "R_ref:\n" << R_ref << std::endl;
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
{
std::cout << "R:\n" << R << std::endl;
if (!equal(R_ref, R, epsilon)) {
return EXIT_FAILURE;
}
}
{
R = { 0, 0, -1, 0, -1, 0, -1, 0, 0 };
std::cout << "R:\n" << R << std::endl;
if (!equal(R_ref, R, epsilon)) {
return EXIT_FAILURE;
}
}
#endif
{
R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
std::cout << "R:\n" << R << std::endl;
if (!equal(R_ref, R, epsilon)) {
return EXIT_FAILURE;
}
R << 0, 0, -1, 0, -1, 0, -1, 0, 0;
std::cout << "R:\n" << R << std::endl;
if (!equal(R_ref, R, epsilon)) {
return EXIT_FAILURE;
}
}
}
std::cout << "Test succeed" << std::endl;
return EXIT_SUCCESS;
}
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.