Calculate the shortest distance between an arc and an edge.
1294 int pt_in_arc, pt_in_seg;
1299 lwerror(
"lw_dist2d_seg_arc does not support maxdistance mode");
1309 if ( radius_C < 0.0 )
1315 lwerror(
"lw_dist2d_pt_seg failed in lw_dist2d_seg_arc");
1323 if ( dist_C_D < radius_C )
1329 dist_D_EF = sqrt(radius_C*radius_C - dist_C_D*dist_C_D);
1330 length_A = sqrt((A2->
x-A1->
x)*(A2->
x-A1->
x)+(A2->
y-A1->
y)*(A2->
y-A1->
y));
1333 E.
x = D.
x - (A2->
x-A1->
x) * dist_D_EF / length_A;
1334 E.
y = D.
y - (A2->
y-A1->
y) * dist_D_EF / length_A;
1336 F.
x = D.
x + (A2->
x-A1->
x) * dist_D_EF / length_A;
1337 F.
y = D.
y + (A2->
y-A1->
y) * dist_D_EF / length_A;
1344 if ( pt_in_arc && pt_in_seg )
1356 if ( pt_in_arc && pt_in_seg )
1368 else if ( dist_C_D == radius_C )
1375 if ( pt_in_arc && pt_in_seg )
1389 G.
x = C.
x + (D.
x-C.
x) * radius_C / dist_C_D;
1390 G.
y = C.
y + (D.
y-C.
y) * radius_C / dist_C_D;
1396 if ( pt_in_arc && pt_in_seg )
1408 if ( pt_in_arc & ! pt_in_seg )
1415 else if ( pt_in_seg && ! pt_in_arc )
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) .
#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_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 occation 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.
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...
int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
Structure used in distance-calculations.
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
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...