From e22588e908a9a2b172a8965cfd8767305dcb3459 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Sun, 30 Nov 2025 11:22:18 +0100 Subject: Move around some macro defs --- inc/cad/solve.h | 34 ++++++++++++++++++++++++++++++++++ src/main.c | 36 ------------------------------------ src/solve.c | 6 +++++- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/inc/cad/solve.h b/inc/cad/solve.h index 85b902b..bdfdf94 100644 --- a/inc/cad/solve.h +++ b/inc/cad/solve.h @@ -45,6 +45,38 @@ enum constraint_type { CT_END, }; +#define PP_DISTANCE(C1, C2, D) \ + { \ + .type = CT_POINT_POINT_DISTANCE, \ + .v = D, \ + .c1 = C1, \ + .c2 = C2, \ + } + +#define PL_DISTANCE(C1, C2, D) \ + { \ + .type = CT_POINT_LINE_DISTANCE, \ + .v = D, \ + .c1 = C1, \ + .c2 = C2, \ + } + +#define POINT_ON_LINE(C1, C2) \ + PL_DISTANCE(C1, C2, 0) + +#define LL_ANGLE(C1, C2, D) \ + { \ + .type = CT_LINE_LINE_ANGLE, \ + .v = D, \ + .c1 = C1, \ + .c2 = C2, \ + } + +#define CEND() \ + { \ + .type = CT_END, \ + } + struct path_step { uint64_t i; bool direction; @@ -66,3 +98,5 @@ struct constraint { void alias_point(struct constraints *c, struct component *alias, struct component *target); void add_constraint(struct constraints *c, struct constraint *new); bool solve_constraints(struct constraints *constraints, struct drawing *drawing); + +#define DEG(x) ((x) * M_PI / 180.0) diff --git a/src/main.c b/src/main.c index 964c5c0..6fc50c0 100644 --- a/src/main.c +++ b/src/main.c @@ -10,42 +10,6 @@ #include "cad/solve.h" #include "cad/svg.h" -#define SETSIGN(b, v) ((v) * ((2 * (b)) - 1)) - -#define DEG(x) ((x) * M_PI / 180.0) - -#define PP_DISTANCE(C1, C2, D) \ - { \ - .type = CT_POINT_POINT_DISTANCE, \ - .v = D, \ - .c1 = C1, \ - .c2 = C2, \ - } - -#define PL_DISTANCE(C1, C2, D) \ - { \ - .type = CT_POINT_LINE_DISTANCE, \ - .v = D, \ - .c1 = C1, \ - .c2 = C2, \ - } - -#define POINT_ON_LINE(C1, C2) \ - PL_DISTANCE(C1, C2, 0) - -#define LL_ANGLE(C1, C2, D) \ - { \ - .type = CT_LINE_LINE_ANGLE, \ - .v = D, \ - .c1 = C1, \ - .c2 = C2, \ - } - -#define CEND() \ - { \ - .type = CT_END, \ - } - void plot_point(struct point p) { printf("\n", p.pos[0], -p.pos[1]); } diff --git a/src/solve.c b/src/solve.c index 2a4fa57..b82d8e8 100644 --- a/src/solve.c +++ b/src/solve.c @@ -40,7 +40,7 @@ void add_constraint(struct constraints *c, struct constraint *new) { } -// @IMPROVE: We should do something better than this. I don't really know what. +// @COMPL: We should do something better than this. I don't really know what. struct frontier { struct component *elems[64]; size_t n; @@ -108,6 +108,10 @@ static void build_angle_point_line(struct drawing *drawing, struct constraint *c }); } +// CLEANUP: None of this makes any sense. We shouldn't have to resolve the +// angles separately. We should just be building up the subgraphs correctly, +// and then the solutions for angles will pop out by themselves. So remove this +// once we get subgraph solving working struct angle_search_frame { size_t constraint_i; struct component *head; -- cgit v1.2.3