diff options
-rw-r--r-- | dda.c | 29 |
1 files changed, 4 insertions, 25 deletions
@@ -74,33 +74,12 @@ dda (test_data_t *testdata) double xi = next_sample_x (x0); double e = (xi - x0) * dy - (yi - y0) * dx; - if (dx >= 0) - { - while (e <= 0) - { - double s = sample_step_x_forward (xi); - - e += s * dy; - xi += s; - } - } - else - { - double s = sample_step_x_backward (xi); - - while (e > s * dy) - { - e -= s * dy; - xi -= s; - - s = sample_step_x_backward (xi); - } - } - #if 0 printf ("= = = = %f %f %f %f = = = = \n", x0, y0, x1, y1); #endif + goto step; + while (yi < next_sample_y (y1)) { if (testdata->points[i++] != xi || @@ -111,7 +90,9 @@ dda (test_data_t *testdata) } e -= sample_step_y (yi) * dx; + yi += sample_step_y (yi); + step: if (dx >= 0) { while (e <= 0) @@ -134,8 +115,6 @@ dda (test_data_t *testdata) s = sample_step_x_backward (xi); } } - - yi += sample_step_y (yi); } } |