]> pd.if.org Git - hexagon/blobdiff - hexagon.c
Removed test from default make target.
[hexagon] / hexagon.c
index 61bb47b0fd80429ddd49e57df1e72ebb450cfc12..264734c6c95ee17493d39f0cad5ce411821377da 100644 (file)
--- a/hexagon.c
+++ b/hexagon.c
@@ -12,7 +12,7 @@ static int inversecantor(int cantor, int *x, int *y);
  * domain
  */
 
-double HL_vertexv[] = {
+double HL_vertexv[12] = {
        .577350269189625764509148780502, 0.0,
        .288675134594812882254574390251, 0.5,
        -.288675134594812882254574390251, 0.5,
@@ -20,6 +20,54 @@ double HL_vertexv[] = {
        -.288675134594812882254574390251, -0.5,
        .288675134594812882254574390251, -0.5};
 
+double HL_fand[16] = {
+       0.0, 0.0,
+       .577350269189625764509148780502, 0.0,
+       .288675134594812882254574390251, 0.5,
+       -.288675134594812882254574390251, 0.5,
+       -.577350269189625764509148780502, 0.0,
+       -.288675134594812882254574390251, -0.5,
+       .288675134594812882254574390251, -0.5,
+       .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,
+       .288675134594812882254574390251f, 0.5f,
+       -.288675134594812882254574390251f, 0.5f,
+       -.577350269189625764509148780502f, 0.0f,
+       -.288675134594812882254574390251f, -0.5f,
+       .288675134594812882254574390251f, -0.5f,
+       .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 */
@@ -437,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 */