closest_point_calculation(): improve "closest point is on segment" detection
This commit is contained in:
parent
a53ea21026
commit
9e1feacab4
|
|
@ -420,12 +420,12 @@ static int closest_point_calculation(double x1, double y1, double x2, double y2,
|
|||
}
|
||||
sq_distance = (*x0 - x3) * (*x0 - x3) + (*y0 - y3) * (*y0 - y3);
|
||||
|
||||
if(x3 >= x1 && x3 <= x2) { /* point is within x1,y1 - x2,y2 */
|
||||
if(projection <= 1 && projection >= 0) { /* point is within x1,y1 - x2,y2 */
|
||||
if(sq_distance == 0) ret = 2;
|
||||
else if(sq_distance < sq_cs) ret = 1;
|
||||
}
|
||||
|
||||
dbg(1, "x3 = %g y3=%g dist=%g ret=%d\n", x3, y3, sqrt(sq_distance), ret);
|
||||
dbg(0, "x3 = %g y3=%g dist=%g ret=%d\n", x3, y3, sqrt(sq_distance), ret);
|
||||
if(ret == 1) {
|
||||
*x0 = my_round(x3 / cs) * cs;
|
||||
*y0 = my_round(y3 / cs) * cs;
|
||||
|
|
|
|||
Loading…
Reference in New Issue