diff options
-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 || |