diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-15 01:18:36 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-15 01:18:36 -0700 |
commit | eda5d1668dbc8529453b7128c4ec2d51aeb1e783 (patch) | |
tree | 2ee5072865a761c540be454abcb6871358be65ea /board.h | |
parent | 3ffb56f167a1855731b50eebfc484b7cc5f21036 (diff) | |
download | dartboat-eda5d1668dbc8529453b7128c4ec2d51aeb1e783.tar.gz dartboat-eda5d1668dbc8529453b7128c4ec2d51aeb1e783.tar.xz |
split code into multiple files
Diffstat (limited to 'board.h')
-rw-r--r-- | board.h | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -0,0 +1,57 @@ +#ifndef BOARD_H +#define BOARD_H + +#include <stdbool.h> + +// board spec from WDF rules +#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 SEGMENT_MAX_LEN 5 +// 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_STRING(X, D) #X, +#define GEN_RING_OUTER_DIST(X, D) D, +enum ring { + FOREACH_RING(GEN_RING_ENUM) + R_OUT +}; + +struct segment { + enum ring ring; + int sector; +}; + +void init_board(); + +struct ccoords { + double x, y; +}; + +struct pcoords { + double a, r; +}; + +struct segment get_segment(struct pcoords c); +char *segment_name(struct segment seg); +int segment_points(struct segment seg); +bool segment_is_double(struct segment seg); +struct pcoords segment_centre(struct segment seg); +struct segment segment_from_name(char *name); + +#endif |