35 #include <visp3/core/vpCircle.h>
37 #include <visp3/core/vpFeatureDisplay.h>
42 const unsigned int val_7 = 7;
43 const unsigned int val_5 = 5;
73 const unsigned int index_0 = 0;
74 const unsigned int index_1 = 1;
75 const unsigned int index_2 = 2;
76 const unsigned int index_3 = 3;
77 const unsigned int index_4 = 4;
78 const unsigned int index_5 = 5;
79 const unsigned int index_6 = 6;
170 const unsigned int val_6 = 6;
171 const unsigned int val_5 = 5;
172 double det_threshold = 1e-10;
174 const unsigned int index_0 = 0;
175 const unsigned int index_1 = 1;
176 const unsigned int index_2 = 2;
177 const unsigned int index_3 = 3;
178 const unsigned int index_4 = 4;
179 const unsigned int index_5 = 5;
183 double A = cP_[index_0];
184 double B = cP_[index_1];
185 double C = cP_[index_2];
187 double X0 = cP_[index_3];
188 double Y0 = cP_[index_4];
189 double Z0 = cP_[index_5];
194 double s = ((X0 * X0) + (Y0 * Y0) + (Z0 * Z0)) - (r * r);
195 double det = (A * X0) + (B * Y0) + (C * Z0);
200 K[index_0] = (1 - (val_2 * A * X0)) + (A * A * s);
201 K[index_1] = (1 - (val_2 * B * Y0)) + (B * B * s);
202 K[index_2] = ((-A * Y0) - (B * X0)) + (A * B * s);
203 K[index_3] = ((-C * X0) - (A * Z0)) + (A * C * s);
204 K[index_4] = ((-C * Y0) - (B * Z0)) + (B * C * s);
205 K[index_5] = (1 - (val_2 * C * Z0)) + (C * C * s);
208 double det = (K[index_2] * K[index_2]) - (K[index_0] * K[index_1]);
209 if (fabs(det) < det_threshold) {
213 double xc = ((K[index_1] * K[index_3]) - (K[index_2] * K[index_4])) / det;
214 double yc = ((K[index_0] * K[index_4]) - (K[index_2] * K[index_3])) / det;
216 double c = sqrt(((K[index_0] - K[index_1]) * (K[index_0] - K[index_1])) + (4 * K[index_2] * K[index_2]));
217 double s = 2 * (((K[index_0] * xc * xc) + (2 * K[index_2] * xc * yc) + (K[1] * yc * yc)) - K[index_5]);
221 if (fabs(K[index_2]) < std::numeric_limits<double>::epsilon()) {
224 A = sqrt(s / ((K[0] + K[1]) + c));
225 B = sqrt(s / ((K[0] + K[1]) - c));
228 A = sqrt(s / ((K[0] + K[1]) - c));
229 B = sqrt(s / ((K[0] + K[1]) + c));
233 E = ((K[1] - K[0]) + c) / (val_2 * K[index_2]);
235 A = sqrt(s / ((K[0] + K[1]) + c));
236 B = sqrt(s / ((K[0] + K[1]) - c));
239 A = sqrt(s / ((K[0] + K[1]) - c));
240 B = sqrt(s / ((K[0] + K[1]) + c));
270 const unsigned int val_7 = 7;
274 const unsigned int index_0 = 0;
275 const unsigned int index_1 = 1;
276 const unsigned int index_2 = 2;
277 const unsigned int index_3 = 3;
278 const unsigned int index_4 = 4;
279 const unsigned int index_5 = 5;
280 const unsigned int index_6 = 6;
281 A = (noMo[index_0][0] *
oP[0]) + (noMo[index_0][1] *
oP[1]) + (noMo[index_0][index_2] *
oP[index_2]);
282 B = (noMo[index_1][0] *
oP[0]) + (noMo[index_1][1] *
oP[1]) + (noMo[index_1][index_2] *
oP[index_2]);
283 C = (noMo[index_2][0] *
oP[0]) + (noMo[index_2][1] *
oP[1]) + (noMo[index_2][index_2] *
oP[index_2]);
286 X0 = noMo[index_0][index_3] + (noMo[index_0][0] *
oP[index_3]) + (noMo[index_0][1] *
oP[index_4]) + (noMo[index_0][index_2] *
oP[index_5]);
287 Y0 = noMo[index_1][index_3] + (noMo[index_1][0] *
oP[index_3]) + (noMo[index_1][1] *
oP[index_4]) + (noMo[index_1][index_2] *
oP[index_5]);
288 Z0 = noMo[index_2][index_3] + (noMo[index_2][0] *
oP[index_3]) + (noMo[index_2][1] *
oP[index_4]) + (noMo[index_2][index_2] *
oP[index_5]);
311 const unsigned int index_0 = 0;
312 const unsigned int index_1 = 1;
313 const unsigned int index_2 = 2;
314 const unsigned int index_3 = 3;
315 const unsigned int index_4 = 4;
316 const unsigned int index_5 = 5;
317 const unsigned int index_6 = 6;
318 A = (cMo[index_0][0] *
oP[0]) + (cMo[index_0][1] *
oP[1]) + (cMo[index_0][index_2] *
oP[index_2]);
319 B = (cMo[index_1][0] *
oP[0]) + (cMo[index_1][1] *
oP[1]) + (cMo[index_1][index_2] *
oP[index_2]);
320 C = (cMo[index_2][0] *
oP[0]) + (cMo[index_2][1] *
oP[1]) + (cMo[index_2][index_2] *
oP[index_2]);
323 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]);
324 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]);
325 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]);
349 unsigned int thickness)
351 const unsigned int index_0 = 0;
352 const unsigned int index_1 = 1;
353 const unsigned int index_2 = 2;
354 const unsigned int index_3 = 3;
355 const unsigned int index_4 = 4;
369 unsigned int thickness)
371 const unsigned int index_0 = 0;
372 const unsigned int index_1 = 1;
373 const unsigned int index_2 = 2;
374 const unsigned int index_3 = 3;
375 const unsigned int index_4 = 4;
391 const vpColor &color,
unsigned int thickness)
396 const unsigned int index_0 = 0;
397 const unsigned int index_1 = 1;
398 const unsigned int index_2 = 2;
399 const unsigned int index_3 = 3;
400 const unsigned int index_4 = 4;
416 const vpColor &color,
unsigned int thickness)
421 const unsigned int index_0 = 0;
422 const unsigned int index_1 = 1;
423 const unsigned int index_2 = 2;
424 const unsigned int index_3 = 3;
425 const unsigned int index_4 = 4;
454 const double &theta,
double &i,
double &j)
462 const unsigned int index_0 = 0;
463 const unsigned int index_1 = 1;
464 const unsigned int index_2 = 2;
465 const unsigned int index_3 = 3;
466 const unsigned int index_4 = 4;
468 double n11 = circle.
p[index_3];
469 double n02 = circle.
p[index_4];
470 double n20 = circle.
p[index_2];
471 double Xg = u0 + (circle.
p[index_0] * px);
472 double Yg = v0 + (circle.
p[index_1] * py);
477 double stheta = sin(theta);
478 double ctheta = cos(theta);
479 double sctheta = stheta * ctheta;
480 double m11yg = n11 * Yg;
482 double m02xg = n02 * Xg;
483 double m11stheta = n11 * stheta;
484 j = ((((((((n11 * Xg * sctheta) - (n20 * Yg * sctheta)) + (n20 * rho * ctheta)) - m11yg) + (m11yg * ctheta2) + m02xg) -
485 (m02xg * ctheta2)) + (m11stheta * rho)) /
486 (((n20 * ctheta2) + (2.0 * m11stheta * ctheta) + n02) - (n02 * ctheta2)));
488 double rhom02 = rho * n02;
489 double sctheta2 = stheta * ctheta2;
490 double ctheta3 = ctheta2 * ctheta;
491 i = (-(((((((-rho * n11 * stheta * ctheta) - rhom02) + (rhom02 * ctheta2) + (n11 * Xg * sctheta2)) - (n20 * Yg * sctheta2)) -
492 (ctheta * n11 * Yg)) + (ctheta3 * n11 * Yg) + (ctheta * n02 * Xg)) - (ctheta3 * n02 * Xg)) /
493 (((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)