[GRASS-SVN] r64199 - grass/trunk/lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 15 12:45:55 PST 2015


Author: mmetz
Date: 2015-01-15 12:45:55 -0800 (Thu, 15 Jan 2015)
New Revision: 64199

Modified:
   grass/trunk/lib/vector/diglib/linecros.c
Log:
diglib: add numerical stability to dig_test_for_intersection()

Modified: grass/trunk/lib/vector/diglib/linecros.c
===================================================================
--- grass/trunk/lib/vector/diglib/linecros.c	2015-01-15 20:44:15 UTC (rev 64198)
+++ grass/trunk/lib/vector/diglib/linecros.c	2015-01-15 20:45:55 UTC (rev 64199)
@@ -62,6 +62,26 @@
     register double d, d1, d2;
     double t;
 
+    if (ax1 > ax2 || (ax1 == ax2 && ay1 > ay2)) {
+	t = ax1;
+	ax1 = ax2;
+	ax2 = t;
+
+	t = ay1;
+	ay1 = ay2;
+	ay2 = t;
+    }
+
+    if (bx1 > bx2 || (bx1 == bx2 && by1 > by2)) {
+	t = bx1;
+	bx1 = bx2;
+	bx2 = t;
+
+	t = by1;
+	by1 = by2;
+	by2 = t;
+    }
+
     d = D;
     d1 = D1;
     d2 = D2;



More information about the grass-commit mailing list