Visual Servoing Platform  version 3.6.1 under development (2024-10-18)
testPoint.cpp

Performs various tests on the the point class.

/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
*
* This software is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact Inria about acquiring a ViSP Professional
* Edition License.
*
* See https://visp.inria.fr for more information.
*
* This software was developed at:
* Inria Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
*
* If you have questions regarding the use of this file, please contact
* Inria at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Description:
* Performs various tests on the point class.
*/
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpMath.h>
#include <visp3/core/vpPoint.h>
#include <visp3/visual_features/vpFeatureBuilder.h>
#include <visp3/visual_features/vpFeatureException.h>
#include <visp3/visual_features/vpFeaturePoint.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
try {
cMo[0][3] = 0.1;
cMo[1][3] = 0.2;
cMo[2][3] = 2;
vpPoint point;
vpTRACE("set point coordinates in the world frame ");
point.setWorldCoordinates(0, 0, 0);
std::cout << "------------------------------------------------------" << std::endl;
vpTRACE("test the projection ");
point.track(cMo);
vpTRACE("coordinates in the world frame ");
std::cout << point.oP.t() << std::endl;
vpTRACE("coordinates in the camera frame ");
std::cout << point.cP.t() << std::endl;
vpTRACE("2D coordinates ");
std::cout << point.get_x() << " " << point.get_y() << std::endl;
std::cout << "------------------------------------------------------" << std::endl;
vpTRACE("test the interaction matrix ");
L = p.interaction();
std::cout << L << std::endl;
vpTRACE("test the interaction matrix select");
vpTRACE("\t only X");
std::cout << L << std::endl;
vpTRACE("\t only Y");
std::cout << L << std::endl;
vpTRACE("\t X & Y");
std::cout << L << std::endl;
vpTRACE("\t selectAll");
std::cout << L << std::endl;
std::cout << "------------------------------------------------------" << std::endl;
vpTRACE("test the error ");
try {
pd.set_x(0);
pd.set_y(0);
pd.print();
std::cout << std::endl;
e = p.error(pd);
std::cout << e << std::endl;
vpTRACE("test the interaction matrix select");
vpTRACE("\t only X");
std::cout << e << std::endl;
vpTRACE("\t only Y");
std::cout << e << std::endl;
vpTRACE("\t X & Y");
std::cout << e << std::endl;
vpTRACE("\t selectAll");
std::cout << e << std::endl;
}
catch (vpFeatureException &me) {
std::cout << me << std::endl;
}
catch (const vpException &me) {
std::cout << me << std::endl;
}
std::cout << "------------------------------------------------------" << std::endl;
vpTRACE("test the dimension");
unsigned int dim;
dim = p.getDimension();
std::cout << "Dimension = " << dim << std::endl;
vpTRACE("test the dimension with select");
vpTRACE("\t only X");
std::cout << "Dimension = " << dim << std::endl;
vpTRACE("\t only Y");
std::cout << "Dimension = " << dim << std::endl;
vpTRACE("\t X & Y");
std::cout << "Dimension = " << dim << std::endl;
vpTRACE("\t selectAll");
std::cout << "Dimension = " << dim << std::endl;
return EXIT_SUCCESS;
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
}
static unsigned int selectAll()
Select all the features.
unsigned int getDimension(unsigned int select=FEATURE_ALL) const
Get the feature vector dimension.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
vpRowVector t() const
error that can be emitted by ViSP classes.
Definition: vpException.h:60
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpImagePoint &t)
Error that can be emitted by the vpBasicFeature class and its derivates.
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
static unsigned int selectX()
vpColVector error(const vpBasicFeature &s_star, unsigned int select=FEATURE_ALL) VP_OVERRIDE
void print(unsigned int select=FEATURE_ALL) const VP_OVERRIDE
static unsigned int selectY()
vpMatrix interaction(unsigned int select=FEATURE_ALL) VP_OVERRIDE
void set_y(double y)
void set_x(double x)
void track(const vpHomogeneousMatrix &cMo)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:79
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.cpp:422
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.cpp:420
void setWorldCoordinates(double oX, double oY, double oZ)
Definition: vpPoint.cpp:111
vpColVector cP
Definition: vpTracker.h:73