50 #include <visp/vpThetaUVector.h>
53 #define vpDEBUG_LEVEL1 0
55 const double vpThetaUVector::minimum = 0.0001;
117 double s,c,theta,sinc;
119 s = (R[1][0]-R[0][1])*(R[1][0]-R[0][1])
120 + (R[2][0]-R[0][2])*(R[2][0]-R[0][2])
121 + (R[2][1]-R[1][2])*(R[2][1]-R[1][2]);
123 c = (R[0][0]+R[1][1]+R[2][2]-1.0)/2.0;
127 if ( (1+c) > minimum)
131 r[0] = (R[2][1]-R[1][2])/(2*sinc);
132 r[1] = (R[0][2]-R[2][0])/(2*sinc);
133 r[2] = (R[1][0]-R[0][1])/(2*sinc);
137 if ( (R[0][0]-c) < std::numeric_limits<double>::epsilon() )
140 r[0] = theta*(sqrt((R[0][0]-c)/(1-c)));
141 if ((R[2][1]-R[1][2]) < 0)
r[0] = -
r[0];
143 if ( (R[1][1]-c) < std::numeric_limits<double>::epsilon() )
146 r[1] = theta*(sqrt((R[1][1]-c)/(1-c)));
148 if ((R[0][2]-R[2][0]) < 0)
r[1] = -
r[1];
150 if ( (R[2][2]-c) < std::numeric_limits<double>::epsilon() )
153 r[2] = theta*(sqrt((R[2][2]-c)/(1-c)));
155 if ((R[1][0]-R[0][1]) < 0)
r[2] = -
r[2];
158 #if (vpDEBUG_LEVEL1) // test new version wrt old version
166 s = (R[1][0]-R[0][1])*(R[1][0]-R[0][1])
167 + (R[2][0]-R[0][2])*(R[2][0]-R[0][2])
168 + (R[2][1]-R[1][2])*(R[2][1]-R[1][2]);
170 c = (R[0][0]+R[1][1]+R[2][2]-1)/2.0;
176 r2[0] = (R[2][1]-R[1][2])/(2*s);
177 r2[1] = (R[0][2]-R[2][0])/(2*s);
178 r2[2] = (R[1][0]-R[0][1])/(2*s);
182 r2[0] = (sqrt((R[0][0]-c)/(1-c)));
183 if ((R[2][1]-R[1][2]) < 0) r2[0] = -r2[0];
184 r2[1] = (sqrt((R[1][1]-c)/(1-c)));
185 if ((R[0][2]-R[2][0]) < 0) r2[1] = -r2[1];
186 r2[2] = (sqrt((R[2][2]-c)/(1-c)));
187 if ((R[1][0]-R[0][1]) < 0) r2[2] = -r2[2];
189 for (i=0;i<3;i++) r2[i] = r2[i]*ang;
193 r2[0] = r2[1] = r2[2] = 0.0;
201 if (fabs(
r[i] - r2[i]) > 1e-5) pb = 1;
205 printf(
"vpThetaUVector::buildFrom(const vpRotationMatrix& R)\n");
206 printf(
" r : %lf %lf %lf\n",
r[0],
r[1],
r[2]);
207 printf(
" r2 : %lf %lf %lf\n",r2[0],r2[1],r2[2]);
208 printf(
" r - r2 : %lf %lf %lf\n",
r[0]-r2[0],
r[1]-r2[1],
r[2]-r2[2]);
275 for (
int i=0; i< 3; i++)
297 theta = sqrt(
r[0]*
r[0] +
r[1]*
r[1] +
r[2]*
r[2]);
299 if (std::fabs(theta) <= std::numeric_limits<double>::epsilon()) {
303 for (
unsigned int i=0 ; i < 3 ; i++)
304 u[i] = r[i] / theta ;
307 #undef vpDEBUG_LEVEL1
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.
vpThetaUVector & operator=(double x)
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...
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)