diff options
author | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2010-12-05 08:05:57 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2010-12-20 10:48:49 -0500 |
commit | 9e72f38adf29a0459611646fc5daf930809c0db5 (patch) | |
tree | 642fb47599c189459622b77d4e716bb23bb3c4d0 | |
parent | a8d4a2ce61839f9a4caa750aec34b80a7f8f6adc (diff) |
Introduce dxdy
-rw-r--r-- | dda.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -54,12 +54,15 @@ dda (test_data_t *testdata) double y0 = testdata->segment.y0; double x1 = testdata->segment.x1; double y1 = testdata->segment.y1; - double y = next_sample_y (y0); int i = 0; + + double dxdy = (x1 - x0) / (y1 - y0); + double y = next_sample_y (y0); + while (y < next_sample_y (y1)) { - double x = ((y - y0) / (y1 - y0)) * (x1 - x0) + x0; + double x = (y - y0) * dxdy + x0; double xi = next_sample_x (x); if (testdata->points[i++] != xi || |