Calculate the shortest distance between an arc and an edge.
1357{
1359 double radius_C;
1361 double dist_C_D;
1362 int pt_in_arc, pt_in_seg;
1364
1365
1367 lwerror(
"lw_dist2d_seg_arc does not support maxdistance mode");
1368
1369
1372
1373
1375
1376
1377 if (radius_C < 0.0)
1379
1380
1383 lwerror(
"lw_dist2d_pt_seg failed in lw_dist2d_seg_arc");
1384
1387
1388
1389
1390
1391 if (dist_C_D < radius_C)
1392 {
1393 double length_A;
1395 double dist_D_EF;
1396
1397 dist_D_EF = sqrt(radius_C * radius_C - dist_C_D * dist_C_D);
1398 length_A = sqrt((A2->
x - A1->
x) * (A2->
x - A1->
x) + (A2->
y - A1->
y) * (A2->
y - A1->
y));
1399
1400
1401 E.
x = D.
x - (A2->
x - A1->
x) * dist_D_EF / length_A;
1402 E.
y = D.
y - (A2->
y - A1->
y) * dist_D_EF / length_A;
1403
1404 F.
x = D.
x + (A2->
x - A1->
x) * dist_D_EF / length_A;
1405 F.
y = D.
y + (A2->
y - A1->
y) * dist_D_EF / length_A;
1406
1407
1410
1411 if (pt_in_arc && pt_in_seg)
1412 {
1415 }
1416
1417
1420
1421 if (pt_in_arc && pt_in_seg)
1422 {
1425 }
1426 }
1427
1428
1429
1430
1431 else if (dist_C_D == radius_C)
1432 {
1433
1436
1437
1438 if (pt_in_arc && pt_in_seg)
1439 {
1442 }
1443 }
1444
1445
1446
1447 else
1448 {
1450 G.
x = C.
x + (D.
x - C.
x) * radius_C / dist_C_D;
1451 G.
y = C.
y + (D.
y - C.
y) * radius_C / dist_C_D;
1452
1455
1456
1457 if (pt_in_arc && pt_in_seg)
1459 }
1460
1461
1462
1463
1464
1465
1466
1467
1468 if (pt_in_arc && !pt_in_seg)
1469 {
1473 }
1474
1475 else if (pt_in_seg && !pt_in_arc)
1476 {
1480 }
1481
1482 else
1483 {
1489 }
1490
1492}
#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_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
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 void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
static void lw_dist2d_distpts_set(DISTPTS *dl, double distance, const POINT2D *p1, const POINT2D *p2)
int lw_dist2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B, DISTPTS *dl)
lw_dist2d_comp from p to line A->B This one is now sending every occasion to lw_dist2d_pt_pt Before i...
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.
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
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...
Structure used in distance-calculations.