[GRASS-SVN] r52520 - grass/trunk/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 4 11:24:41 PDT 2012
Author: mmetz
Date: 2012-08-04 11:24:40 -0700 (Sat, 04 Aug 2012)
New Revision: 52520
Modified:
grass/trunk/lib/vector/diglib/inside.c
Log:
diglib: optimize dig_x_intersect
Modified: grass/trunk/lib/vector/diglib/inside.c
===================================================================
--- grass/trunk/lib/vector/diglib/inside.c 2012-08-04 18:21:34 UTC (rev 52519)
+++ grass/trunk/lib/vector/diglib/inside.c 2012-08-04 18:24:40 UTC (rev 52520)
@@ -21,9 +21,18 @@
dig_x_intersect(double beg_x,
double end_x, double beg_y, double end_y, double Y)
{
- double b, a;
+ double b;
+
+ /* solve simple linear equation to get X = a + b * Y
+ * with
+ * b = (end_x - beg_x) / (end_y - beg_y)
+ * a = beg_x - b * beg_y
+ *
+ * simplify a + b * Y:
+ * a + b * Y = beg_x - b * beg_y + b * Y
+ * a + b * Y = beg_x + b * (Y - beg_y) */
b = (end_x - beg_x) / (end_y - beg_y);
- a = beg_x - b * beg_y;
- return (a + b * Y);
+
+ return beg_x + b * (Y - beg_y);
}
More information about the grass-commit
mailing list