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.
2218{
2220
2221 LWDEBUG(2,
"lw_dist2d_pt_seg called");
2222
2223
2224 if ((A->
x == B->
x) && (A->
y == B->
y))
2225 {
2226 LWDEBUG(2,
"lw_dist2d_pt_seg found first and last segment points being the same");
2228 }
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
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));
2248
2249 LWDEBUGF(2,
"lw_dist2d_pt_seg found r = %.15g",
r);
2250
2251
2252
2254 {
2257 else
2259 }
2260
2265
2266
2267 if ((((A->
y - p->
y) * (B->
x - A->
x) == (A->
x - p->
x) * (B->
y - A->
y))) && (dl->
mode ==
DIST_MIN))
2268 {
2270 }
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
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));
2284
2285 double dist = fabs(
s) * sqrt(((B->
x - A->
x) * (B->
x - A->
x) + (B->
y - A->
y) * (B->
y - A->
y)));
2287 {
2289 {
2291 c.
x = A->
x +
r * (B->
x - A->
x);
2292 c.
y = A->
y +
r * (B->
y - A->
y);
2294 {
2297 }
2298 else
2299 {
2302 }
2303 }
2304 }
2305
2307}
#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().