Definition at line 2354 of file measures.c.
2355{
2356
2357 if ((A->
x == B->
x) && (A->
y == B->
y))
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375 double ba_x = (B->
x - A->
x);
2376 double ba_y = (B->
y - A->
y);
2377 double ab_length_sqr = (ba_x * ba_x + ba_y * ba_y);
2378 double ca_x = (C->x - A->
x);
2379 double ca_y = (C->y - A->
y);
2380 double dot_ac_ab = (ca_x * ba_x + ca_y * ba_y);
2381
2382 if (dot_ac_ab <= 0)
2384 if (dot_ac_ab >= ab_length_sqr)
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397 double s_numerator = ca_x * ba_y - ca_y * ba_x;
2398
2399
2400 return s_numerator * s_numerator / ab_length_sqr;
2401}
static double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
References distance2d_sqr_pt_pt(), POINT2D::x, and POINT2D::y.
Referenced by lwline_split_by_point_to(), ptarray_closest_segment_2d(), and ptarray_locate_point().