]> pd.if.org Git - isea/blob - t/hexbin.c
Initial checkin.
[isea] / t / hexbin.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "tap.h"
5 #include "hex.h"
6
7 void iso(struct hex *h) {
8         hex_iso(h);
9         printf("iso(%d,%d,%d)", h->x, h->y, h->z);
10 }
11 void xy(struct hex *h) {
12         hex_xy(h);
13         printf("xy(%d,%d)", h->x, h->y);
14 }
15
16 int main(void) {
17         int x, y;
18         double p, q;
19
20         plan_tests(5);
21
22         hexbin2(0, 1.0, 0.0, 0.0, &x, &y);
23         ok(x == 0 && y == 0, "0.0 0.0 -> 0 0");
24
25         hexbin2(0, 0.1111111, 0.288675, 0.500000, &x, &y);
26         ok(x == 3, "center bin X %d == 3", x);
27         ok(y == -5, "center bin Y %d == -5", y);
28
29         hexbin2(0, 0.1111111, 0.866025, 0.500000, &x, &y);
30         ok(x == 9, "vertex bin X %d == 9", x);
31         ok(y == -5, "vertex bin Y %d == -5", y);
32
33         return exit_status();
34
35         for (p = -4.0; p < 4.0; p+= 0.4) {
36                 for (q = -4.0; q < 4.0; q += 0.4) {
37         hexbin2(0, 1.0, p, q, &x, &y);
38         printf("(%f, %f) = %d %d\n", p, q, x, y);
39                 }
40         }
41
42 }
43