Parcourir la source

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 il y a 6 ans
Parent
commit
c5755a9354
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  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;
     double x, y;
-    double dist, curdist;
+    double dist, curdist, dthresh;
 
     /* 1. of A seg */
     seg = asegment;
@@ -251,7 +251,8 @@ static int snap_cross(int asegment, double *adistance, int bsegment,
      * the smallest difference representable with 
      * single precision floating point works well with pathological input
      * 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;
 	*yc = y;