X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=hexagon.c;h=264734c6c95ee17493d39f0cad5ce411821377da;hb=5011228dceecadb0c1ed94c2635d6c0342e2af48;hp=123e5cfa2539928b357a178f3bef9402c685df0f;hpb=b23bb67f8c88ba23499d1c6e7b444b6561aeb49a;p=hexagon diff --git a/hexagon.c b/hexagon.c index 123e5cf..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,21 @@ 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; + /* these all are for a hex one unit across */ static double hexptvd[6][2] = { {.577350269189625764509148780502, 0.0}, /* 1.0/sqrt3 */ @@ -459,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 */