50 #include <visp/vpThetaUVector.h>
53 #define vpDEBUG_LEVEL1 0
55 const double vpThetaUVector::minimum = 0.0001;
63 for (
int i=0; i<3; i++)
139 double s,c,theta,sinc;
141 s = (R[1][0]-R[0][1])*(R[1][0]-R[0][1])
142 + (R[2][0]-R[0][2])*(R[2][0]-R[0][2])
143 + (R[2][1]-R[1][2])*(R[2][1]-R[1][2]);
145 c = (R[0][0]+R[1][1]+R[2][2]-1.0)/2.0;
149 if ( (1+c) > minimum)
153 r[0] = (R[2][1]-R[1][2])/(2*sinc);
154 r[1] = (R[0][2]-R[2][0])/(2*sinc);
155 r[2] = (R[1][0]-R[0][1])/(2*sinc);
159 if ( (R[0][0]-c) < std::numeric_limits<double>::epsilon() )
162 r[0] = theta*(sqrt((R[0][0]-c)/(1-c)));
163 if ((R[2][1]-R[1][2]) < 0)
r[0] = -
r[0];
165 if ( (R[1][1]-c) < std::numeric_limits<double>::epsilon() )
168 r[1] = theta*(sqrt((R[1][1]-c)/(1-c)));
170 if ((R[0][2]-R[2][0]) < 0)
r[1] = -
r[1];
172 if ( (R[2][2]-c) < std::numeric_limits<double>::epsilon() )
175 r[2] = theta*(sqrt((R[2][2]-c)/(1-c)));
177 if ((R[1][0]-R[0][1]) < 0)
r[2] = -
r[2];
180 #if (vpDEBUG_LEVEL1) // test new version wrt old version
188 s = (R[1][0]-R[0][1])*(R[1][0]-R[0][1])
189 + (R[2][0]-R[0][2])*(R[2][0]-R[0][2])
190 + (R[2][1]-R[1][2])*(R[2][1]-R[1][2]);
192 c = (R[0][0]+R[1][1]+R[2][2]-1)/2.0;
198 r2[0] = (R[2][1]-R[1][2])/(2*s);
199 r2[1] = (R[0][2]-R[2][0])/(2*s);
200 r2[2] = (R[1][0]-R[0][1])/(2*s);
204 r2[0] = (sqrt((R[0][0]-c)/(1-c)));
205 if ((R[2][1]-R[1][2]) < 0) r2[0] = -r2[0];
206 r2[1] = (sqrt((R[1][1]-c)/(1-c)));
207 if ((R[0][2]-R[2][0]) < 0) r2[1] = -r2[1];
208 r2[2] = (sqrt((R[2][2]-c)/(1-c)));
209 if ((R[1][0]-R[0][1]) < 0) r2[2] = -r2[2];
211 for (i=0;i<3;i++) r2[i] = r2[i]*ang;
215 r2[0] = r2[1] = r2[2] = 0.0;
223 if (fabs(
r[i] - r2[i]) > 1e-5) pb = 1;
227 printf(
"vpThetaUVector::buildFrom(const vpRotationMatrix& R)\n");
228 printf(
" r : %lf %lf %lf\n",
r[0],
r[1],
r[2]);
229 printf(
" r2 : %lf %lf %lf\n",r2[0],r2[1],r2[2]);
230 printf(
" r - r2 : %lf %lf %lf\n",
r[0]-r2[0],
r[1]-r2[1],
r[2]-r2[2]);
297 for (
int i=0; i< 3; i++)
319 theta = sqrt(
r[0]*
r[0] +
r[1]*
r[1] +
r[2]*
r[2]);
321 if (std::fabs(theta) <= std::numeric_limits<double>::epsilon()) {
325 for (
unsigned int i=0 ; i < 3 ; i++)
326 u[i] = r[i] / theta ;
329 #undef vpDEBUG_LEVEL1
Class that consider the case of a generic rotation vector (cannot be used as is !) consisting in thre...
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Class that consider the case of the Euler angle using the z-y-x convention, where are respectively ...
vpThetaUVector buildFrom(const vpHomogeneousMatrix &M)
static double sinc(double x)
The vpRotationMatrix considers the particular case of a rotation matrix.
void extract(double &theta, vpColVector &u) const
void extract(vpRotationMatrix &R) const
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpThetaUVector & operator=(const vpThetaUVector &tu)
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...
Class that consider the case of the parameterization for the rotation.
void resize(const unsigned int i, const bool flagNullify=true)