|
static bool | isBetween (double i, double a, double b, double n) |
|
static int | circle_circle_intersection (double x0, double y0, double r0, double x1, double y1, double r1, double *xi, double *yi, double *xi_prime, double *yi_prime) |
|
static int | circleTangentPoints (double x, double y, double x1, double y1, double r1, double *xi, double *yi, double *xi_prime, double *yi_prime) |
|
static double | computeAngle (double x0, double y0, double x1, double y1) |
|
static double | angleVectVect (Vector u, Vector v) |
|
static int | computeChainCode (Point p, Point q) |
|
static int | computeOctant (Point p, Point q) |
|
static int | rot (int d, int quad) |
|
static Vector | chainCode2Vect (int d) |
|
template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
struct DGtal::FrechetShortcut< TIterator, TInteger >::Tools
Definition at line 351 of file FrechetShortcut.h.
template<typename TIterator , typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
static int DGtal::FrechetShortcut< TIterator, TInteger >::Tools::circle_circle_intersection |
( |
double |
x0, |
|
|
double |
y0, |
|
|
double |
r0, |
|
|
double |
x1, |
|
|
double |
y1, |
|
|
double |
r1, |
|
|
double * |
xi, |
|
|
double * |
yi, |
|
|
double * |
xi_prime, |
|
|
double * |
yi_prime |
|
) |
| |
|
inlinestatic |
Determine the points where two circles in a common plane intersect Parameters: three doubles per circle (center, radius), pointers to the two intersection points
- Returns
- 0 if the circles do not intersect each other, 1 otherwise
Definition at line 397 of file FrechetShortcut.h.
401 {
402 double a, dx, dy, d, h, rx, ry;
403 double x2, y2;
404
405
406
407
408 dx = x1 - x0;
409 dy = y1 - y0;
410
411
412
413 d = hypot(dx,dy);
414
415
416 if (d > (r0 + r1))
417 {
418
419 std::cerr << "Warning : the two circles do not intersect -> should never happen" << std::endl;
420 return 0;
421 }
422 if (d < fabs(r0 - r1))
423 {
424
425 return 0;
426 }
427
428
429
430
431
432
433
434 a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ;
435
436
437 x2 = x0 + (dx * a/d);
438 y2 = y0 + (dy * a/d);
439
440
441
442
443 h = sqrt((r0*r0) - (a*a));
444
445
446
447
448 rx = -dy * (h/d);
449 ry = dx * (h/d);
450
451
452 *xi = x2 + rx;
453 *xi_prime = x2 - rx;
454 *yi = y2 + ry;
455 *yi_prime = y2 - ry;
456
457 return 1;
458 }
Referenced by DGtal::FrechetShortcut< TIterator, TInteger >::Tools::circleTangentPoints().
template<typename TIterator , typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
static int DGtal::FrechetShortcut< TIterator, TInteger >::Tools::circleTangentPoints |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
x1, |
|
|
double |
y1, |
|
|
double |
r1, |
|
|
double * |
xi, |
|
|
double * |
yi, |
|
|
double * |
xi_prime, |
|
|
double * |
yi_prime |
|
) |
| |
|
inlinestatic |
Given a point X and a circle of center X1, compute the two points Xi and Xi' of the circle the tangent of which go through X. Since the triangle XXiX1 is a right triangle on Xi, the middle point M between X and X1 is equidistant to X, X1 and Xi. Thus, Xi belongs to the intersection of the circle (X1,r1) and the circle of center M and radius ||XX1||/2.
- Parameters
-
[in] | x | the first coordinate of X. |
[in] | y | the second coordinate of X. |
[in] | x1 | the first coordinate of the circle center X1. |
[in] | y1 | the second coordinate of the circle center X1. |
[in] | r1 | the circle radius. |
[out] | xi | pointer to the first coordinate of the first intersection point. |
[out] | yi | pointer to the second coordinate of the first intersection point. |
[out] | xi_prime | pointer to the first coordinate of the second intersection point. |
[out] | yi_prime | pointer to the second coordinate of the second intersection point. |
- Returns
- result of the call to circle_circle_intersection
Definition at line 481 of file FrechetShortcut.h.
483 {
484 double x0 = (x+x1)/2;
485 double y0 = (y+y1)/2;
486 double r0 = sqrt((x-x1)*(x-x1) + (y-y1)*(y-y1))/2;
487
488 int res =
490
491 return res;
492
493 }
References DGtal::FrechetShortcut< TIterator, TInteger >::Tools::circle_circle_intersection().