summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-12-05 08:08:38 -0500
committerSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-12-20 10:48:49 -0500
commit755178b6326b7458268c3329c120473950cd4d08 (patch)
tree8a6de112927ae2c78d35e65165fe99a8f6c86225
parent9e72f38adf29a0459611646fc5daf930809c0db5 (diff)
Compute X incrementally
-rw-r--r--dda.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/dda.c b/dda.c
index 9e7db61..91357ee 100644
--- a/dda.c
+++ b/dda.c
@@ -56,13 +56,12 @@ dda (test_data_t *testdata)
double y1 = testdata->segment.y1;
int i = 0;
-
double dxdy = (x1 - x0) / (y1 - y0);
double y = next_sample_y (y0);
+ double x = (y - y0) * dxdy + x0;
while (y < next_sample_y (y1))
{
- double x = (y - y0) * dxdy + x0;
double xi = next_sample_x (x);
if (testdata->points[i++] != xi ||
@@ -72,6 +71,8 @@ dda (test_data_t *testdata)
exit (-1);
}
+ x += sample_step_y (y) * dxdy;
+
y += sample_step_y (y);
}
}