1498 double radius_A, radius_B, d;
1500 int pt_in_arc_A, pt_in_arc_B;
1503 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1520 if ( radius_A < 0 && radius_B < 0 )
1537 B1, B2, B3, radius_B,
1541 if ( radius_B > radius_A )
1546 tmp = B1; B1 = A1; A1 = tmp;
1547 tmp = B2; B2 = A2; A2 = tmp;
1548 tmp = B3; B3 = A3; A3 = tmp;
1549 TP = CB; CB = CA; CA = TP;
1550 td = radius_B; radius_B = radius_A; radius_A = td;
1554 if ( d == (radius_A + radius_B) )
1556 D.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1557 D.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1563 if ( pt_in_arc_A && pt_in_arc_B )
1573 else if ( d > (radius_A + radius_B) || d < (radius_A - radius_B) )
1580 XA.
x = CA.
x + (CB.
x - CA.
x) * radius_A / d;
1581 XA.
y = CA.
y + (CB.
y - CA.
y) * radius_A / d;
1582 XB.
x = CB.
x + (CA.
x - CB.
x) * radius_B / d;
1583 XB.
y = CB.
y + (CA.
y - CB.
y) * radius_B / d;
1590 if ( pt_in_arc_A && pt_in_arc_B )
1597 else if ( d < (radius_A + radius_B) )
1601 double a = (radius_A*radius_A - radius_B*radius_B + d*d) / (2*d);
1603 double h = sqrt(radius_A*radius_A - a*a);
1606 D.
x = CA.
x + (CB.
x - CA.
x) * a / d;
1607 D.
y = CA.
y + (CB.
y - CA.
y) * a / d;
1610 E.
x = D.
x + (D.
y - CA.
y) * h / a;
1611 E.
y = D.
y + (D.
x - CA.
x) * h / a;
1617 if ( pt_in_arc_A && pt_in_arc_B )
1619 dl->
p1 = dl->
p2 = E;
1625 F.
x = D.
x - (D.
y - CA.
y) * h / a;
1626 F.
y = D.
y - (D.
x - CA.
x) * h / a;
1632 if ( pt_in_arc_A && pt_in_arc_B )
1634 dl->
p1 = dl->
p2 = F;
1641 lwerror(
"lw_dist2d_arc_arc: arcs neither touch, intersect nor are disjoint! INCONCEIVABLE!");
1647 if ( pt_in_arc_A & ! pt_in_arc_B )
1655 else if ( pt_in_arc_B && ! pt_in_arc_A )
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_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)
#define LW_TRUE
Return types for functions with status returns.
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, 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_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...
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
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.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...