#include #include #include "bresenham-distribution.h" static void show(uintmax_t N, uintmax_t B, int centered) { printf("%s: N=%" PRIuMAX ", B=%" PRIuMAX ":", centered ? "BD-C" : "BD-0", N, B); for (uintmax_t b = 0; b < B; ++b) printf(" %" PRIuMAX, centered ? bd_count_c(N, B, b) : bd_count_0(N, B, b)); putchar('\n'); } int main(void) { show(93, 10, 0); /* BD-0: heavy buckets 3, 6, 9. */ show(93, 10, 1); /* BD-C: heavy buckets 2, 5, 8. */ show(83, 9, 0); /* BD-0: heavy buckets 4, 8. */ show(83, 9, 1); /* BD-C: heavy buckets 2, 6. */ show(103, 11, 1); /* BD-C: balanced margins, but not mirror-symmetric. */ show(89, 9, 1); /* BD-C: the single light bucket is centered at 4. */ /* Fixed N and B: visit every phase once. Each bucket gets R extras. */ uintmax_t extras[9] = {0}; for (uintmax_t shift = 0; shift < 9; ++shift) for (uintmax_t b = 0; b < 9; ++b) extras[b] += bd_count(83, 9, b, shift) - 83 / 9; printf("Extras over all 9 phases:"); for (uintmax_t b = 0; b < 9; ++b) printf(" %" PRIuMAX, extras[b]); putchar('\n'); return 0; }