50 #include <visp/vpThetaUVector.h>
53 #define vpDEBUG_LEVEL1 0
55 const double vpThetaUVector::minimum = 0.0001;
123 for(
unsigned int i=0; i<3; i++)
135 double s,c,theta,sinc;
137 s = (R[1][0]-R[0][1])*(R[1][0]-R[0][1])
138 + (R[2][0]-R[0][2])*(R[2][0]-R[0][2])
139 + (R[2][1]-R[1][2])*(R[2][1]-R[1][2]);
141 c = (R[0][0]+R[1][1]+R[2][2]-1.0)/2.0;
145 if ( (1+c) > minimum)
149 r[0] = (R[2][1]-R[1][2])/(2*sinc);
150 r[1] = (R[0][2]-R[2][0])/(2*sinc);
151 r[2] = (R[1][0]-R[0][1])/(2*sinc);
155 if ( (R[0][0]-c) < std::numeric_limits<double>::epsilon() )
158 r[0] = theta*(sqrt((R[0][0]-c)/(1-c)));
159 if ((R[2][1]-R[1][2]) < 0)
r[0] = -
r[0];
161 if ( (R[1][1]-c) < std::numeric_limits<double>::epsilon() )
164 r[1] = theta*(sqrt((R[1][1]-c)/(1-c)));
166 if ((R[0][2]-R[2][0]) < 0)
r[1] = -
r[1];
168 if ( (R[2][2]-c) < std::numeric_limits<double>::epsilon() )
171 r[2] = theta*(sqrt((R[2][2]-c)/(1-c)));
173 if ((R[1][0]-R[0][1]) < 0)
r[2] = -
r[2];
176 #if (vpDEBUG_LEVEL1) // test new version wrt old version
184 s = (R[1][0]-R[0][1])*(R[1][0]-R[0][1])
185 + (R[2][0]-R[0][2])*(R[2][0]-R[0][2])
186 + (R[2][1]-R[1][2])*(R[2][1]-R[1][2]);
188 c = (R[0][0]+R[1][1]+R[2][2]-1)/2.0;
194 r2[0] = (R[2][1]-R[1][2])/(2*s);
195 r2[1] = (R[0][2]-R[2][0])/(2*s);
196 r2[2] = (R[1][0]-R[0][1])/(2*s);
200 r2[0] = (sqrt((R[0][0]-c)/(1-c)));
201 if ((R[2][1]-R[1][2]) < 0) r2[0] = -r2[0];
202 r2[1] = (sqrt((R[1][1]-c)/(1-c)));
203 if ((R[0][2]-R[2][0]) < 0) r2[1] = -r2[1];
204 r2[2] = (sqrt((R[2][2]-c)/(1-c)));
205 if ((R[1][0]-R[0][1]) < 0) r2[2] = -r2[2];
207 for (i=0;i<3;i++) r2[i] = r2[i]*ang;
211 r2[0] = r2[1] = r2[2] = 0.0;
219 if (fabs(
r[i] - r2[i]) > 1e-5) pb = 1;
223 printf(
"vpThetaUVector::buildFrom(const vpRotationMatrix& R)\n");
224 printf(
" r : %lf %lf %lf\n",
r[0],
r[1],
r[2]);
225 printf(
" r2 : %lf %lf %lf\n",r2[0],r2[1],r2[2]);
226 printf(
" r - r2 : %lf %lf %lf\n",
r[0]-r2[0],
r[1]-r2[1],
r[2]-r2[2]);
293 for (
int i=0; i< 3; i++)
315 theta = sqrt(
r[0]*
r[0] +
r[1]*
r[1] +
r[2]*
r[2]);
317 if (std::fabs(theta) <= std::numeric_limits<double>::epsilon()) {
321 for (
unsigned int i=0 ; i < 3 ; i++)
322 u[i] = r[i] / theta ;
325 #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...
The pose is a complete representation of every rigid motion in the euclidian space.
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)