X-Git-Url: https://pd.if.org/git/?p=hexagon;a=blobdiff_plain;f=hexagon.c;h=264734c6c95ee17493d39f0cad5ce411821377da;hp=bd07f256d18f1d30d73ce61c3b7d6a17ea9a68c1;hb=800280caf177d1a84d134f99b0b8835f19e74aa5;hpb=ca7198be26f8b84d708dffbe2a946ad5846cd10e diff --git a/hexagon.c b/hexagon.c index bd07f25..264734c 100644 --- a/hexagon.c +++ b/hexagon.c @@ -31,6 +31,17 @@ double HL_fand[16] = { .577350269189625764509148780502, 0.0 }; +double HL_hfand[16] = { + 0.0, 0.0, + 0.0, .577350269189625764509148780502, + 0.5, .288675134594812882254574390251, + 0.5, -.288675134594812882254574390251, + 0.0, -.577350269189625764509148780502, + -0.5, -.288675134594812882254574390251, + -0.5, .288675134594812882254574390251, + 0.0, .577350269189625764509148780502 +}; + float HL_fanf[16] = { 0.0f, 0.0f, .577350269189625764509148780502f, 0.0f, @@ -42,6 +53,17 @@ float HL_fanf[16] = { .577350269189625764509148780502f, 0.0f }; +float HL_hfanf[16] = { + 0.0f, 0.0f, + 0.0f, .577350269189625764509148780502f, + 0.5f, .288675134594812882254574390251f, + 0.5f, -.288675134594812882254574390251f, + 0.0f, -.577350269189625764509148780502f, + -0.5f, -.288675134594812882254574390251f, + -0.5f, .288675134594812882254574390251f, + 0.0f, .577350269189625764509148780502f +}; + /* size of a square that will exactly fit in a hexagon */ /* 2.0/(1+sqrt(3.0)) */ double HL_square = .73205080756887729352; @@ -463,14 +485,16 @@ static int hex_iso(struct hex *h) { #endif +#define COS30 (.866025403784438646763723170752) + int HL_hexbin(double width, double x, double y, int *i, int *j) { double z, rx, ry, rz; double abs_dx, abs_dy, abs_dz; int ix, iy, iz, s; struct hex h; - /* TODO just hard-code this cosine */ - x = x / cos(30 * M_PI / 180.0); /* rotated X coord */ + /*x = x / cos(30 * M_PI / 180.0); */ /* rotated X coord */ + x = x / COS30; y = y - x / 2.0; /* adjustment for rotated X */ /* adjust for actual hexwidth */