35 #include <visp3/core/vpCircle.h>
37 #include <visp3/core/vpFeatureDisplay.h>
71 const unsigned int index_0 = 0;
72 const unsigned int index_1 = 1;
73 const unsigned int index_2 = 2;
74 const unsigned int index_3 = 3;
75 const unsigned int index_4 = 4;
76 const unsigned int index_5 = 5;
77 const unsigned int index_6 = 6;
166 double det_threshold = 1e-10;
168 const unsigned int index_0 = 0;
169 const unsigned int index_1 = 1;
170 const unsigned int index_2 = 2;
171 const unsigned int index_3 = 3;
172 const unsigned int index_4 = 4;
173 const unsigned int index_5 = 5;
177 double A = cP_[index_0];
178 double B = cP_[index_1];
179 double C = cP_[index_2];
181 double X0 = cP_[index_3];
182 double Y0 = cP_[index_4];
183 double Z0 = cP_[index_5];
188 double s = ((X0 * X0) + (Y0 * Y0) + (Z0 * Z0)) - (r * r);
189 double det = (A * X0) + (B * Y0) + (C * Z0);
194 K[index_0] = (1 - (2 * A * X0)) + (A * A * s);
195 K[index_1] = (1 - (2 * B * Y0)) + (B * B * s);
196 K[index_2] = ((-A * Y0) - (B * X0)) + (A * B * s);
197 K[index_3] = ((-C * X0) - (A * Z0)) + (A * C * s);
198 K[index_4] = ((-C * Y0) - (B * Z0)) + (B * C * s);
199 K[index_5] = (1 - (2 * C * Z0)) + (C * C * s);
202 double det = (K[index_2] * K[index_2]) - (K[index_0] * K[index_1]);
203 if (fabs(det) < det_threshold) {
207 double xc = ((K[index_1] * K[index_3]) - (K[index_2] * K[index_4])) / det;
208 double yc = ((K[index_0] * K[index_4]) - (K[index_2] * K[index_3])) / det;
210 double c = sqrt(((K[index_0] - K[index_1]) * (K[index_0] - K[index_1])) + (4 * K[index_2] * K[index_2]));
211 double s = 2 * (((K[index_0] * xc * xc) + (2 * K[index_2] * xc * yc) + (K[1] * yc * yc)) - K[index_5]);
215 if (fabs(K[index_2]) < std::numeric_limits<double>::epsilon()) {
218 A = sqrt(s / ((K[0] + K[1]) + c));
219 B = sqrt(s / ((K[0] + K[1]) - c));
222 A = sqrt(s / ((K[0] + K[1]) - c));
223 B = sqrt(s / ((K[0] + K[1]) + c));
227 E = ((K[1] - K[0]) + c) / (2 * K[index_2]);
229 A = sqrt(s / ((K[0] + K[1]) + c));
230 B = sqrt(s / ((K[0] + K[1]) - c));
233 A = sqrt(s / ((K[0] + K[1]) - c));
234 B = sqrt(s / ((K[0] + K[1]) + c));
267 const unsigned int index_0 = 0;
268 const unsigned int index_1 = 1;
269 const unsigned int index_2 = 2;
270 const unsigned int index_3 = 3;
271 const unsigned int index_4 = 4;
272 const unsigned int index_5 = 5;
273 const unsigned int index_6 = 6;
274 A = (noMo[index_0][0] *
oP[0]) + (noMo[index_0][1] *
oP[1]) + (noMo[index_0][index_2] *
oP[index_2]);
275 B = (noMo[index_1][0] *
oP[0]) + (noMo[index_1][1] *
oP[1]) + (noMo[index_1][index_2] *
oP[index_2]);
276 C = (noMo[index_2][0] *
oP[0]) + (noMo[index_2][1] *
oP[1]) + (noMo[index_2][index_2] *
oP[index_2]);
279 X0 = noMo[index_0][index_3] + (noMo[index_0][0] *
oP[3]) + (noMo[index_0][1] *
oP[index_4]) + (noMo[index_0][index_2] *
oP[index_5]);
280 Y0 = noMo[index_1][index_3] + (noMo[index_1][0] *
oP[3]) + (noMo[index_1][1] *
oP[index_4]) + (noMo[index_1][index_2] *
oP[index_5]);
281 Z0 = noMo[index_2][index_3] + (noMo[index_2][0] *
oP[3]) + (noMo[index_2][1] *
oP[index_4]) + (noMo[index_2][index_2] *
oP[index_5]);
304 const unsigned int index_0 = 0;
305 const unsigned int index_1 = 1;
306 const unsigned int index_2 = 2;
307 const unsigned int index_3 = 3;
308 const unsigned int index_4 = 4;
309 const unsigned int index_5 = 5;
310 const unsigned int index_6 = 6;
311 A = (cMo[index_0][0] *
oP[0]) + (cMo[index_0][1] *
oP[1]) + (cMo[index_0][index_2] *
oP[index_2]);
312 B = (cMo[index_1][0] *
oP[0]) + (cMo[index_1][1] *
oP[1]) + (cMo[index_1][index_2] *
oP[index_2]);
313 C = (cMo[index_2][0] *
oP[0]) + (cMo[index_2][1] *
oP[1]) + (cMo[index_2][index_2] *
oP[index_2]);
316 X0 = cMo[index_0][index_3] + (cMo[index_0][0] *
oP[index_3]) + (cMo[index_0][1] *
oP[index_4]) + (cMo[index_0][index_2] *
oP[index_5]);
317 Y0 = cMo[index_1][index_3] + (cMo[index_1][0] *
oP[index_3]) + (cMo[index_1][1] *
oP[index_4]) + (cMo[index_1][index_2] *
oP[index_5]);
318 Z0 = cMo[index_2][index_3] + (cMo[index_2][0] *
oP[index_3]) + (cMo[index_2][1] *
oP[index_4]) + (cMo[index_2][index_2] *
oP[index_5]);
342 unsigned int thickness)
344 const unsigned int index_0 = 0;
345 const unsigned int index_1 = 1;
346 const unsigned int index_2 = 2;
347 const unsigned int index_3 = 3;
348 const unsigned int index_4 = 4;
362 unsigned int thickness)
364 const unsigned int index_0 = 0;
365 const unsigned int index_1 = 1;
366 const unsigned int index_2 = 2;
367 const unsigned int index_3 = 3;
368 const unsigned int index_4 = 4;
384 const vpColor &color,
unsigned int thickness)
389 const unsigned int index_0 = 0;
390 const unsigned int index_1 = 1;
391 const unsigned int index_2 = 2;
392 const unsigned int index_3 = 3;
393 const unsigned int index_4 = 4;
409 const vpColor &color,
unsigned int thickness)
414 const unsigned int index_0 = 0;
415 const unsigned int index_1 = 1;
416 const unsigned int index_2 = 2;
417 const unsigned int index_3 = 3;
418 const unsigned int index_4 = 4;
447 const double &theta,
double &i,
double &j)
455 const unsigned int index_0 = 0;
456 const unsigned int index_1 = 1;
457 const unsigned int index_2 = 2;
458 const unsigned int index_3 = 3;
459 const unsigned int index_4 = 4;
461 double n11 = circle.
p[index_3];
462 double n02 = circle.
p[index_4];
463 double n20 = circle.
p[index_2];
464 double Xg = u0 + (circle.
p[index_0] * px);
465 double Yg = v0 + (circle.
p[index_1] * py);
470 double stheta = sin(theta);
471 double ctheta = cos(theta);
472 double sctheta = stheta * ctheta;
473 double m11yg = n11 * Yg;
475 double m02xg = n02 * Xg;
476 double m11stheta = n11 * stheta;
477 j = ((((((((n11 * Xg * sctheta) - (n20 * Yg * sctheta)) + (n20 * rho * ctheta)) - m11yg) + (m11yg * ctheta2) + m02xg) -
478 (m02xg * ctheta2)) + (m11stheta * rho)) /
479 (((n20 * ctheta2) + (2.0 * m11stheta * ctheta) + n02) - (n02 * ctheta2)));
481 double rhom02 = rho * n02;
482 double sctheta2 = stheta * ctheta2;
483 double ctheta3 = ctheta2 * ctheta;
484 i = (-(((((((-rho * n11 * stheta * ctheta) - rhom02) + (rhom02 * ctheta2) + (n11 * Xg * sctheta2)) - (n20 * Yg * sctheta2)) -
485 (ctheta * n11 * Yg)) + (ctheta3 * n11 * Yg) + (ctheta * n02 * Xg)) - (ctheta3 * n02 * Xg)) /
486 (((n20 * ctheta2) + (2.0 * n11 * stheta * ctheta) + n02) - (n02 * ctheta2)) / stheta);
Generic class defining intrinsic camera parameters.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
void display(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1) VP_OVERRIDE
void changeFrame(const vpHomogeneousMatrix &noMo, vpColVector &noP) const VP_OVERRIDE
void projection() VP_OVERRIDE
void setWorldCoordinates(const vpColVector &oP) VP_OVERRIDE
vpCircle * duplicate() const VP_OVERRIDE
For memory issue (used by the vpServo class only)
static void computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j)
virtual ~vpCircle() VP_OVERRIDE
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
Class to define RGB colors available for display functionalities.
error that can be emitted by ViSP classes.
@ divideByZeroError
Division by zero.
static void displayEllipse(double x, double y, double n20, double n11, double n02, const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static double sqr(double x)