50 #include <visp/vpMath.h>
51 #include <visp/vpRotationMatrix.h>
52 #include <visp/vpParseArgv.h>
53 #include <visp/vpQuaternionVector.h>
60 #define GETOPTARGS "h"
62 void usage(
const char *name,
const char *badparam);
63 bool getOptions(
int argc,
const char **argv);
70 void usage(
const char *name,
const char *badparam)
73 Tests transformation within various representations of rotation.\n\
84 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
93 bool getOptions(
int argc,
const char **argv)
100 case 'h': usage(argv[0], NULL);
return false;
break;
103 usage(argv[0], optarg_);
108 if ((c == 1) || (c == -1)) {
110 usage(argv[0], NULL);
111 std::cerr <<
"ERROR: " << std::endl;
112 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
121 main(
int argc,
const char ** argv)
125 if (getOptions(argc, argv) ==
false) {
129 for(
int i=-10;i<10;i++){
130 for(
int j=-10;j<10;j++){
134 std::cout <<
"Initialization " <<std::endl ;
138 tu.extract(theta, u);
140 std::cout <<
"theta=" <<
vpMath::deg(theta) << std::endl ;
141 std::cout <<
"u=" << u << std::endl ;
143 std::cout <<
"From vpThetaUVector to vpRotationMatrix " << std::endl ;
146 std::cout <<
"Matrix R" ;
147 if (R.
isARotationMatrix()==1) std::cout <<
" is a rotation matrix " << std::endl ;
148 else std::cout <<
" is not a rotation matrix " << std::endl ;
150 std::cout << R << std::endl ;
152 std::cout <<
"From vpRotationMatrix to vpQuaternionVector " << std::endl ;
154 std::cout << q <<std::endl ;
157 std::cout <<
"From vpQuaternionVector to vpRotationMatrix " << std::endl ;
159 std::cout <<
"From vpRotationMatrix to vpRxyzVector " << std::endl ;
161 std::cout << RxyzBuildFromR <<std::endl ;
164 std::cout <<
"From vpRxyzVector to vpThetaUVector " << std::endl ;
165 std::cout <<
" use From vpRxyzVector to vpRotationMatrix " << std::endl ;
166 std::cout <<
" use From vpRotationMatrix to vpThetaUVector " << std::endl ;
172 std::cout << std::endl ;
173 std::cout <<
"result : should equivalent to the first one " << std::endl ;
179 tuBuildFromEu.
extract(theta2, u2);
180 std::cout <<
"theta=" <<
vpMath::deg(theta2) << std::endl ;
181 std::cout <<
"u=" << u2 << std::endl ;
183 assert(
vpMath::abs(theta2-theta)<std::numeric_limits<double>::epsilon()*1e10);
184 assert(
vpMath::abs(u[0]-u2[0])<std::numeric_limits<double>::epsilon()*1e10);
185 assert(
vpMath::abs(u[1]-u2[1])<std::numeric_limits<double>::epsilon()*1e10);
186 assert(
vpMath::abs(u[2]-u2[2])<std::numeric_limits<double>::epsilon()*1e10);
189 std::cout <<
"Initialization vpRzyzVector " <<std::endl ;
190 std::cout << rzyz << std::endl ;
191 std::cout <<
"From vpRzyzVector to vpRotationMatrix " << std::endl ;
193 std::cout <<
"From vpRotationMatrix to vpRzyzVector " << std::endl ;
196 std::cout << rzyz_final << std::endl ;
200 std::cout <<
"Initialization vpRzyxVector " <<std::endl ;
201 std::cout << rzyx << std::endl ;
202 std::cout <<
"From vpRzyxVector to vpRotationMatrix " << std::endl ;
204 std::cout << R << std::endl ;
205 std::cout <<
"From vpRotationMatrix to vpRzyxVector " << std::endl ;
208 std::cout << rzyx_final << std::endl ;
213 std::cout <<
"Catch an exception: " << e << std::endl;
error that can be emited by ViSP classes.
Class that consider the case of the Euler angle using the z-y-x convention, where are respectively ...
vpThetaUVector buildFrom(const vpHomogeneousMatrix &M)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
static Type abs(const Type &x)
bool isARotationMatrix() const
test if the matrix is an rotation matrix
The vpRotationMatrix considers the particular case of a rotation matrix.
void extract(double &theta, vpColVector &u) const
vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M)
Build a rotation matrix from an homogeneous matrix.
Defines a quaternion and its basic operations.
void buildFrom(const double phi, const double theta, const double psi)
static double rad(double deg)
static double deg(double rad)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Class that consider the case of the Euler angle using the x-y-z convention, where are respectively ...
Class that consider the case of the Euler angles using the z-y-z convention, where are respectively...
void buildFrom(const double phi, const double theta, const double psi)
Class that consider the case of the parameterization for the rotation.