#ifndef BOARD_H #define BOARD_H #include // board spec from WDF rules #define DIAMETER 451.0 #define WIRE_WIDTH 1.56 #define INNER_DIAMETER_BULL 12.7 #define INNER_DIAMETER_25 31.8 #define DOUBLE_OUTER_EDGE 170.0 #define TREBLE_OUTER_EDGE 107.4 #define DOUBLE_INSIDE_WIDTH 8.0 #define TREBLE_INSIDE_WIDTH 8.0 #define NUM_SECTORS 20 #define SECTOR_WIDTH (360.0 / NUM_SECTORS) #define FOREACH_SECTOR(M) \ M(1) M(2) M(3) M(4) M(5) M(6) M(7) M(8) M(9) M(10) \ M(11) M(12) M(13) M(14) M(15) M(16) M(17) M(18) M(19) M(20) #define GEN_SECTOR_STR(X) #X, #define GEN_SECTOR_STR_D(X) "D" #X, #define GEN_SECTOR_STR_T(X) "T" #X, // distance from centre to apex of outer wire // must be ordered outwards from centre #define FOREACH_RING(M) \ M(BULL, (INNER_DIAMETER_BULL / 2) + (WIRE_WIDTH / 2)) \ M(25, (INNER_DIAMETER_25 / 2) + (WIRE_WIDTH / 2)) \ M(SMALL, TREBLE_OUTER_EDGE - WIRE_WIDTH - TREBLE_INSIDE_WIDTH - \ (WIRE_WIDTH / 2)) \ M(TREBLE, TREBLE_OUTER_EDGE - (WIRE_WIDTH / 2)) \ M(BIG, DOUBLE_OUTER_EDGE - WIRE_WIDTH - DOUBLE_INSIDE_WIDTH - \ (WIRE_WIDTH / 2)) \ M(DOUBLE, DOUBLE_OUTER_EDGE - (WIRE_WIDTH / 2)) #define GEN_RING_ENUM(X, D) R_ ## X, #define GEN_RING_STR(X, D) #X, #define GEN_RING_OUTER_DIST(X, D) (D), extern int SECTORS[]; extern double OUTER_DISTS[]; enum ring { FOREACH_RING(GEN_RING_ENUM) R_OUT }; struct segment { enum ring ring; int sector; }; struct ccoords { double x, y; }; struct pcoords { double a, r; }; void init_board(); struct ccoords pol_to_cart(struct pcoords c); struct pcoords cart_to_pol(struct ccoords c); struct segment segment_from_pcoords(struct pcoords c); struct segment segment_from_name(const char *name); struct pcoords segment_centre(struct segment seg); const char *segment_name(struct segment seg); int segment_points(struct segment seg); bool segment_is_double(struct segment seg); #endif