diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2026-02-10 22:28:56 +0100 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2026-02-10 22:28:56 +0100 |
| commit | 1598929f5b86c3541b9faf51f12b85b63945f0c0 (patch) | |
| tree | 4b8d26df8887af2d0eb338a7a0d21a28ea39fb3a /test/solve.c | |
| parent | 3c4954f1dfe0cda7da2e7f4b7f60eac88ce22fa3 (diff) | |
Detect partial solves
Diffstat (limited to 'test/solve.c')
| -rw-r--r-- | test/solve.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/solve.c b/test/solve.c new file mode 100644 index 0000000..ea767f4 --- /dev/null +++ b/test/solve.c @@ -0,0 +1,47 @@ +#include "cad/solve.h" +#include <assert.h> + +int main(int argc, char *argv[]) { + { + struct constraints constraints = {}; + + struct component p1 = {.type = COM_POINT}; + struct component p2 = {.type = COM_POINT}; + struct component p3 = {.type = COM_POINT}; + + struct component p4 = {.type = COM_POINT}; + struct component p5 = {.type = COM_POINT}; + + struct component t1base = {.type = COM_LINE}; + struct component t2base = {.type = COM_LINE}; + + add_constraint(&constraints, (struct constraint[]){ + // Make a triangle + PP_DISTANCE(&p1, &p2, 30), + PP_DISTANCE(&p1, &p3, 30), + PP_DISTANCE(&p2, &p3, 30), + + POINT_ON_LINE(&p1, &t1base), + POINT_ON_LINE(&p2, &t1base), + + // With another triangle sharing the topmost point + PP_DISTANCE(&p4, &p5, 30), + PP_DISTANCE(&p3, &p4, 30), + PP_DISTANCE(&p3, &p5, 30), + + POINT_ON_LINE(&p4, &t2base), + POINT_ON_LINE(&p5, &t2base), + + // The edge they don't share is constrained + LL_ANGLE(&t1base, &t2base, DEG(40)), + CEND(), + }); + + struct drawing drawing = {}; + bool solved = solve_constraints(&constraints, &drawing); + + assert(!solved); + } + + return 0; +} |
