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 2227 of file measures.c.
2231 LWDEBUG(2,
"lw_dist2d_pt_seg called");
2234 if ((A->
x == B->
x) && (A->
y == B->
y))
2236 LWDEBUG(2,
"lw_dist2d_pt_seg found first and last segment points being the same");
2256 r = ((p->
x - A->
x) * (B->
x - A->
x) + (p->
y - A->
y) * (B->
y - A->
y)) /
2257 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2259 LWDEBUGF(2,
"lw_dist2d_pt_seg found r = %.15g",
r);
2277 if ((((A->
y - p->
y) * (B->
x - A->
x) == (A->
x - p->
x) * (B->
y - A->
y))) && (dl->
mode ==
DIST_MIN))
2292 double s = ((A->
y - p->
y) * (B->
x - A->
x) - (A->
x - p->
x) * (B->
y - A->
y)) /
2293 ((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y));
2295 double dist = fabs(
s) * sqrt(((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y)));
2301 c.
x = A->
x +
r * (B->
x - A->
x);
2302 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().