[GRASS-SVN] r64196 - grass/branches/releasebranch_7_0/lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 15 12:37:27 PST 2015


Author: mmetz
Date: 2015-01-15 12:37:27 -0800 (Thu, 15 Jan 2015)
New Revision: 64196

Modified:
   grass/branches/releasebranch_7_0/lib/vector/diglib/inside.c
Log:
diglib: add numerical stability to dig_x_intersect()

Modified: grass/branches/releasebranch_7_0/lib/vector/diglib/inside.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/diglib/inside.c	2015-01-15 20:37:10 UTC (rev 64195)
+++ grass/branches/releasebranch_7_0/lib/vector/diglib/inside.c	2015-01-15 20:37:27 UTC (rev 64196)
@@ -22,7 +22,20 @@
 		double end_x, double beg_y, double end_y, double Y)
 {
     double b;
-    
+
+    /* assumes beg_y != end_y */
+
+    /* sort for numerical stability */
+    if (end_y < beg_y) {
+	b = end_x;
+	end_x = beg_x;
+	beg_x = b;
+
+	b = end_y;
+	end_y = beg_y;
+	beg_y = b;
+    }
+
     /* solve simple linear equation to get X = a + b * Y
      * with
      * b = (end_x - beg_x) / (end_y - beg_y)



More information about the grass-commit mailing list