diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2025-11-23 19:47:02 +0100 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2025-11-23 19:47:02 +0100 |
| commit | 84f11b37d178242d4ff80c4f3b4eddb54efe59ea (patch) | |
| tree | c19cf2167f40e0c96130ef3acdae0a998daeccab | |
| parent | 9c0110122693400366bd52a49b7d4645eae3de57 (diff) | |
Don't reorder parameters
| -rw-r--r-- | src/main.c | 6 | ||||
| -rw-r--r-- | src/solve.c | 26 |
2 files changed, 16 insertions, 16 deletions
@@ -326,18 +326,18 @@ int main(int argc, char *argv[]) { if(!constraints.elements[i].used) continue; if(constraints.elements[i].order == 0) continue; - params[constraints.elements[i].order-1] = SETSIGN(constraints.elements[i].forward, constraints.elements[i].v); + params[i] = SETSIGN(constraints.elements[i].forward, constraints.elements[i].v); // We need to offset angles based on the path we took to use this // constraint if(constraints.elements[i].path[0].i != -1) { // printf("PATH %ld order %llu\n", i, constraints[i].order-1); for(struct path_step *p = constraints.elements[i].path; p <= constraints.elements[i].path+SEARCH_DEPTH && p->i != -1; p++) { - params[constraints.elements[i].order-1] += SETSIGN(p->direction, constraints.elements[p->i].v); + params[i] += SETSIGN(p->direction, constraints.elements[p->i].v); // printf("%llu [%d:%f] [%f] -> ", p->i, p->direction, constraints[p->i].v, params[constraints[i].order-1]); } // printf("\n"); - params[constraints.elements[i].order-1] -= (M_PI*2.0) * floor(params[constraints.elements[i].order-1] / (M_PI*2.0)); + params[i] -= (M_PI*2.0) * floor(params[i] / (M_PI*2.0)); // printf("Final Angle is %f\n", params[constraints[i].order-1]); } diff --git a/src/solve.c b/src/solve.c index 9a629f4..be16663 100644 --- a/src/solve.c +++ b/src/solve.c @@ -60,20 +60,20 @@ static void add_frontier(struct frontier *frontier, struct component *component) frontier->elems[frontier->n++] = component; } -static void build_angle_point_line(struct drawing *drawing, struct constraint *i, struct constraint *j, struct component *local_i, struct component *local_j, struct component *oppo_i) { +static void build_angle_point_line(struct drawing *drawing, size_t index_i, size_t index_j, struct component *local_i, struct component *local_j, struct component *oppo_i) { assert(local_i->e != NULL); assert(local_j->e != NULL); assert(local_i->type == COM_LINE); assert(local_j->type == COM_POINT); struct element *theta = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = i->order-1, + .index = index_i, .result.type = ETYPE_VALUE, }); struct element *d = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = j->order-1, + .index = index_j, .result.type = ETYPE_VALUE, }); @@ -394,13 +394,13 @@ static void draw_solution(struct constraint *constraints, size_t fix, struct sol } else { struct element *d1 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->i].order-1, + .index = step->i, .result.type = ETYPE_VALUE, }); struct element *d2 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->j].order-1, + .index = step->j, .result.type = ETYPE_VALUE, }); @@ -436,12 +436,12 @@ static void draw_solution(struct constraint *constraints, size_t fix, struct sol struct element *d1 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->i].order-1, + .index = step->i, .result.type = ETYPE_VALUE, }); struct element *d2 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->j].order-1, + .index = step->j, .result.type = ETYPE_VALUE, }); @@ -476,12 +476,12 @@ static void draw_solution(struct constraint *constraints, size_t fix, struct sol struct element *d1 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->i].order-1, + .index = step->i, .result.type = ETYPE_VALUE, }); struct element *d2 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->j].order-1, + .index = step->j, .result.type = ETYPE_VALUE, }); @@ -517,7 +517,7 @@ static void draw_solution(struct constraint *constraints, size_t fix, struct sol constraints[step->i].forward = step->i_forward; constraints[step->j].forward = step->j_forward; - build_angle_point_line(drawing, &constraints[step->i], &constraints[step->j], local_i, local_j, oppo_i); + build_angle_point_line(drawing, step->i, step->j, local_i, local_j, oppo_i); } else if(constraints[step->i].type == CT_POINT_LINE_DISTANCE && local_i->type == COM_POINT && constraints[step->j].type == CT_LINE_LINE_ANGLE @@ -527,7 +527,7 @@ static void draw_solution(struct constraint *constraints, size_t fix, struct sol constraints[step->i].forward = step->i_forward; constraints[step->j].forward = step->j_forward; - build_angle_point_line(drawing, &constraints[step->j], &constraints[step->i], local_j, local_i, oppo_i); + build_angle_point_line(drawing, step->j, step->i, local_j, local_i, oppo_i); } else if(constraints[step->i].type == CT_POINT_LINE_DISTANCE && local_i->type == COM_LINE && constraints[step->j].type == CT_POINT_POINT_DISTANCE @@ -536,12 +536,12 @@ static void draw_solution(struct constraint *constraints, size_t fix, struct sol struct element *d1 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->i].order-1, + .index = step->i, .result.type = ETYPE_VALUE, }); struct element *d2 = insert_cmd(drawing, (struct command){ .op = CMD_VALUE_INPUT, - .index = constraints[step->j].order-1, + .index = step->j, .result.type = ETYPE_VALUE, }); |
