Explorar o código

Vlib: adjust dynamic floating point representation error for squared distances

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74031 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz %!s(int64=6) %!d(string=hai) anos
pai
achega
c5755a9354
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      lib/vector/Vlib/intersect2.c

+ 3 - 2
lib/vector/Vlib/intersect2.c

@@ -208,7 +208,7 @@ static int snap_cross(int asegment, double *adistance, int bsegment,
 {
 {
     int seg;
     int seg;
     double x, y;
     double x, y;
-    double dist, curdist;
+    double dist, curdist, dthresh;
 
 
     /* 1. of A seg */
     /* 1. of A seg */
     seg = asegment;
     seg = asegment;
@@ -251,7 +251,8 @@ static int snap_cross(int asegment, double *adistance, int bsegment,
      * the smallest difference representable with 
      * the smallest difference representable with 
      * single precision floating point works well with pathological input
      * single precision floating point works well with pathological input
      * regular input is not affected */
      * regular input is not affected */
-    if (curdist < d_ulp(x, y)) {	/* was rethresh * rethresh */
+    dthresh = d_ulp(x, y);
+    if (curdist < dthresh * dthresh) {	/* was rethresh * rethresh */
 	*xc = x;
 	*xc = x;
 	*yc = y;
 	*yc = y;