10 /* y *must* be positive down as the xy /iso conversion assumes this */
12 int hex_xy(struct hex *h) {
13 if (!h->iso) return 1;
15 h->y = -h->y - (h->x+1)/2;
17 /* need to round toward -inf, not toward zero, so x-1 */
18 h->y = -h->y - h->x/2;
26 int hex_iso(struct hex *h) {
30 h->y = (-h->y - (h->x+1)/2);
32 /* need to round toward -inf, not toward zero, so x-1 */
33 h->y = (-h->y - (h->x)/2);
42 int hexbin2(int horizontal, double width, double x, double y,
45 double abs_dx, abs_dy, abs_dz;
49 x = x / cos(30 * M_PI / 180.0); /* rotated X coord */
50 y = y - x / 2.0; /* adjustment for rotated X */
52 /* adjust for actual hexwidth */
58 ix = rx = floor(x + 0.5);
59 iy = ry = floor(y + 0.5);
60 iz = rz = floor(z + 0.5);
65 abs_dx = fabs(rx - x);
66 abs_dy = fabs(ry - y);
67 abs_dz = fabs(rz - z);
69 if (abs_dx >= abs_dy && abs_dx >= abs_dz) {
71 } else if (abs_dy >= abs_dx && abs_dy >= abs_dz) {