lw_dist2d_comp from p to line A->B This one is now sending every occasion to lw_dist2d_pt_pt Before it was handling occasions where r was between 0 and 1 internally and just returning the distance without identifying the points.
To get this points it was necessary to change and it also showed to be about 10faster.
Definition at line 2316 of file measures.c.
2320 LWDEBUG(2,
"lw_dist2d_pt_seg called");
2323 if ((A->
x == B->
x) && (A->
y == B->
y))
2325 LWDEBUG(2,
"lw_dist2d_pt_seg found first and last segment points being the same");
2345 r = ((p->
x - A->
x) * (B->
x - A->
x) + (p->
y - A->
y) * (B->
y - A->
y)) /
2346 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2348 LWDEBUGF(2,
"lw_dist2d_pt_seg found r = %.15g",
r);
2366 if ((((A->
y - p->
y) * (B->
x - A->
x) == (A->
x - p->
x) * (B->
y - A->
y))) && (dl->
mode ==
DIST_MIN))
2383 double s = ((A->
y - p->
y) * (B->
x - A->
x) - (A->
x - p->
x) * (B->
y - A->
y)) /
2384 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2386 double dist = fabs(
s) * sqrt(((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y)));
2392 c.
x = A->
x +
r * (B->
x - A->
x);
2393 c.
y = A->
y +
r * (B->
y - A->
y);
#define LW_TRUE
Return types for functions with status returns.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
static double distance(double x1, double y1, double x2, double y2)
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...
References DIST_MAX, DIST_MIN, distance(), DISTPTS::distance, lw_dist2d_pt_pt(), LW_TRUE, LWDEBUG, LWDEBUGF, DISTPTS::mode, DISTPTS::p1, DISTPTS::p2, r, s, DISTPTS::twisted, POINT2D::x, and POINT2D::y.
Referenced by lw_dist2d_pt_arc(), lw_dist2d_pt_ptarray(), lw_dist2d_seg_arc(), lw_dist2d_seg_seg(), lw_dist2d_selected_seg_seg(), rect_leaf_node_distance(), and rect_leaf_node_intersects().