[GRASS-SVN] r64195 - grass/trunk/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 15 12:37:10 PST 2015
Author: mmetz
Date: 2015-01-15 12:37:10 -0800 (Thu, 15 Jan 2015)
New Revision: 64195
Modified:
grass/trunk/lib/vector/diglib/inside.c
Log:
diglib: add numerical stability to dig_x_intersect()
Modified: grass/trunk/lib/vector/diglib/inside.c
===================================================================
--- grass/trunk/lib/vector/diglib/inside.c 2015-01-15 19:32:27 UTC (rev 64194)
+++ grass/trunk/lib/vector/diglib/inside.c 2015-01-15 20:37:10 UTC (rev 64195)
@@ -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