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 2217 of file measures.c.
2221 LWDEBUG(2,
"lw_dist2d_pt_seg called");
2224 if ((A->
x == B->
x) && (A->
y == B->
y))
2226 LWDEBUG(2,
"lw_dist2d_pt_seg found first and last segment points being the same");
2246 r = ((p->
x - A->
x) * (B->
x - A->
x) + (p->
y - A->
y) * (B->
y - A->
y)) /
2247 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2249 LWDEBUGF(2,
"lw_dist2d_pt_seg found r = %.15g",
r);
2267 if ((((A->
y - p->
y) * (B->
x - A->
x) == (A->
x - p->
x) * (B->
y - A->
y))) && (dl->
mode ==
DIST_MIN))
2282 double s = ((A->
y - p->
y) * (B->
x - A->
x) - (A->
x - p->
x) * (B->
y - A->
y)) /
2283 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2285 double dist = fabs(
s) * sqrt(((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y)));
2291 c.
x = A->
x +
r * (B->
x - A->
x);
2292 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)
static void lw_dist2d_distpts_set(DISTPTS *dl, double distance, const POINT2D *p1, const POINT2D *p2)
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_distpts_set(), 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().