1502 double radius_A, radius_B, d;
1504 int pt_in_arc_A, pt_in_arc_B;
1507 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1524 if ( radius_A < 0 && radius_B < 0 )
1541 B1, B2, B3, radius_B,
1545 if ( radius_B > radius_A )
1550 tmp = B1; B1 = A1; A1 = tmp;
1551 tmp = B2; B2 = A2; A2 = tmp;
1552 tmp = B3; B3 = A3; A3 = tmp;
1553 TP = CB; CB = CA; CA = TP;
1554 td = radius_B; radius_B = radius_A; radius_A = td;
1558 if ( d == (radius_A + radius_B) )
1560 D.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1561 D.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1567 if ( pt_in_arc_A && pt_in_arc_B )
1577 else if ( d > (radius_A + radius_B) || d < (radius_A - radius_B) )
1584 XA.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1585 XA.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1586 XB.
x = CB.
x + (CA.
x - CB.
x) * radius_B / d;
1587 XB.
y = CB.
y + (CA.
y - CB.
y) * radius_B / d;
1594 if ( pt_in_arc_A && pt_in_arc_B )
1601 else if ( d < (radius_A + radius_B) )
1605 double a = (radius_A*radius_A - radius_B*radius_B + d*d) / (2*d);
1607 double h = sqrt(radius_A*radius_A - a*a);
1610 D.
x = CA.
x + (CB.
x - CA.
x) * a / d;
1611 D.
y = CA.
y + (CB.
y - CA.
y) * a / d;
1614 E.
x = D.
x + (D.
y - CA.
y) * h / a;
1615 E.
y = D.
y + (D.
x - CA.
x) * h / a;
1621 if ( pt_in_arc_A && pt_in_arc_B )
1623 dl->
p1 = dl->
p2 = E;
1629 F.
x = D.
x - (D.
y - CA.
y) * h / a;
1630 F.
y = D.
y - (D.
x - CA.
x) * h / a;
1636 if ( pt_in_arc_A && pt_in_arc_B )
1638 dl->
p1 = dl->
p2 = F;
1645 lwerror(
"lw_dist2d_arc_arc: arcs neither touch, intersect nor are disjoint! INCONCEIVABLE!");
1651 if (pt_in_arc_A && !pt_in_arc_B)
1659 else if ( pt_in_arc_B && ! pt_in_arc_A )
#define LW_TRUE
Return types for functions with status returns.
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if arc A is actually a point (all vertices are the same) .
int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if P is on the same side of the plane partition defined by A1/A3 as A2 is.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
int lw_dist2d_arc_arc_concentric(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, double radius_A, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, double radius_B, const POINT2D *CENTER, DISTPTS *dl)
int lw_dist2d_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
Finds the shortest distance between two segments.
int lw_dist2d_seg_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Calculate the shortest distance between an arc and an edge.
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...