39 #include <visp3/core/vpCircle.h> 41 #include <visp3/core/vpFeatureDisplay.h> 177 double s = X0 * X0 + Y0 * Y0 + Z0 * Z0 - r * r;
178 double det = A * X0 + B * Y0 + C * Z0;
183 K[0] = 1 - 2 * A * X0 + A * A * s;
184 K[1] = 1 - 2 * B * Y0 + B * B * s;
185 K[2] = -A * Y0 - B * X0 + A * B * s;
186 K[3] = -C * X0 - A * Z0 + A * C * s;
187 K[4] = -C * Y0 - B * Z0 + B * C * s;
188 K[5] = 1 - 2 * C * Z0 + C * C * s;
191 double det = K[2] * K[2] - K[0] * K[1];
192 if (fabs(det) < 1e-8) {
196 double xc = (K[1] * K[3] - K[2] * K[4]) / det;
197 double yc = (K[0] * K[4] - K[2] * K[3]) / det;
199 double c = sqrt((K[0] - K[1]) * (K[0] - K[1]) + 4 * K[2] * K[2]);
200 double s = 2 * (K[0] * xc * xc + 2 * K[2] * xc * yc + K[1] * yc * yc - K[5]);
204 if (fabs(K[2]) < std::numeric_limits<double>::epsilon()) {
207 A = sqrt(s / (K[0] + K[1] + c));
208 B = sqrt(s / (K[0] + K[1] - c));
210 A = sqrt(s / (K[0] + K[1] - c));
211 B = sqrt(s / (K[0] + K[1] + c));
214 E = (K[1] - K[0] + c) / (2 * K[2]);
216 A = sqrt(s / (K[0] + K[1] + c));
217 B = sqrt(s / (K[0] + K[1] - c));
219 A = sqrt(s / (K[0] + K[1] - c));
220 B = sqrt(s / (K[0] + K[1] + c));
253 A = noMo[0][0] *
oP[0] + noMo[0][1] *
oP[1] + noMo[0][2] *
oP[2];
254 B = noMo[1][0] * oP[0] + noMo[1][1] * oP[1] + noMo[1][2] * oP[2];
255 C = noMo[2][0] * oP[0] + noMo[2][1] * oP[1] + noMo[2][2] * oP[2];
258 X0 = noMo[0][3] + noMo[0][0] * oP[3] + noMo[0][1] * oP[4] + noMo[0][2] * oP[5];
259 Y0 = noMo[1][3] + noMo[1][0] * oP[3] + noMo[1][1] * oP[4] + noMo[1][2] * oP[5];
260 Z0 = noMo[2][3] + noMo[2][0] * oP[3] + noMo[2][1] * oP[4] + noMo[2][2] * oP[5];
283 A = cMo[0][0] *
oP[0] + cMo[0][1] *
oP[1] + cMo[0][2] *
oP[2];
284 B = cMo[1][0] * oP[0] + cMo[1][1] * oP[1] + cMo[1][2] * oP[2];
285 C = cMo[2][0] * oP[0] + cMo[2][1] * oP[1] + cMo[2][2] * oP[2];
288 X0 = cMo[0][3] + cMo[0][0] * oP[3] + cMo[0][1] * oP[4] + cMo[0][2] * oP[5];
289 Y0 = cMo[1][3] + cMo[1][0] * oP[3] + cMo[1][1] * oP[4] + cMo[1][2] * oP[5];
290 Z0 = cMo[2][3] + cMo[2][0] * oP[3] + cMo[2][1] * oP[4] + cMo[2][2] * oP[5];
314 unsigned int thickness)
329 unsigned int thickness)
346 const vpColor &color,
unsigned int thickness)
366 const vpColor &color,
unsigned int thickness)
399 const double &theta,
double &i,
double &j)
407 double n11 = circle.
p[3];
408 double n02 = circle.
p[4];
409 double n20 = circle.
p[2];
410 double Xg = u0 + circle.
p[0] * px;
411 double Yg = v0 + circle.
p[1] * py;
416 double stheta = sin(theta);
417 double ctheta = cos(theta);
418 double sctheta = stheta * ctheta;
419 double m11yg = n11 * Yg;
421 double m02xg = n02 * Xg;
422 double m11stheta = n11 * stheta;
423 j = ((n11 * Xg * sctheta - n20 * Yg * sctheta + n20 * rho * ctheta - m11yg + m11yg * ctheta2 + m02xg -
424 m02xg * ctheta2 + m11stheta * rho) /
425 (n20 * ctheta2 + 2.0 * m11stheta * ctheta + n02 - n02 * ctheta2));
427 double rhom02 = rho * n02;
428 double sctheta2 = stheta * ctheta2;
429 double ctheta3 = ctheta2 * ctheta;
430 i = (-(-rho * n11 * stheta * ctheta - rhom02 + rhom02 * ctheta2 + n11 * Xg * sctheta2 - n20 * Yg * sctheta2 -
431 ctheta * n11 * Yg + ctheta3 * n11 * Yg + ctheta * n02 * Xg - ctheta3 * n02 * Xg) /
432 (n20 * ctheta2 + 2.0 * n11 * stheta * ctheta + n02 - n02 * ctheta2) / stheta);
void display(const vpImage< unsigned char > &I, const vpCameraParameters &cam, const vpColor &color=vpColor::green, unsigned int thickness=1)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class to define RGB colors available for display functionnalities.
error that can be emited by ViSP classes.
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)
static double sqr(double x)
static void computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j)
Generic class defining intrinsic camera parameters.
void changeFrame(const vpHomogeneousMatrix &noMo, vpColVector &noP) const
void resize(unsigned int i, bool flagNullify=true)
vpCircle * duplicate() const
For memory issue (used by the vpServo class only)
Implementation of column vector and the associated operations.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
void setWorldCoordinates(const vpColVector &oP)