summaryrefslogtreecommitdiff
path: root/src/construction.c
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2026-04-18 16:14:51 +0200
committerJesper Jensen <jesper@jnsn.dev>2026-04-18 16:14:51 +0200
commit2dbf9aed304c69431038d3b37e614e5d45dbcc56 (patch)
tree4caf35d63499d0e80716b5b180fea15d218ddb58 /src/construction.c
parent9688f8f0f685bb93e9d74e7d5e74eeb1939b94aa (diff)
Make the triangle work again
Diffstat (limited to 'src/construction.c')
-rw-r--r--src/construction.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/construction.c b/src/construction.c
index 207dd0f..33f37ad 100644
--- a/src/construction.c
+++ b/src/construction.c
@@ -95,26 +95,25 @@ static void transform_part(struct command *cmd, const struct command *last_cmd,
case CMD_LINE_LINE_DISTANCE_PARALLEL:
// Find a point on the line, what point doesn't matter
// since the whole line is moving
- struct line line = cmd->result.line;
+ struct line *line = &cmd->result.line;
vec2 p;
glm_vec2_zero(p);
- glm_vec2_muladds(line.norm, line.C, p);
- double rec = glm_vec2_norm2(line.norm);
- glm_vec2_divs(p, rec, p);
+ if(line->norm[0] > line->norm[1])
+ glm_vec2_copy((vec2){-line->C / line->norm[0], 0}, p);
+ else
+ glm_vec2_copy((vec2){0, -line->C / line->norm[1]}, p);
// Rotate the line to the new orientation
- affine_transform_vec2(rotate, line.norm, line.norm);
+ affine_transform_vec2(rotate, line->norm, line->norm);
// Transform the fixed point
affine_transform_vec2(transform, p, p);
// Calculate a C to follow the new point
glm_vec2_negate(p);
- line.C = glm_vec2_dot(line.norm, p);
-
- cmd->result.line = line;
+ line->C = glm_vec2_dot(line->norm, p);
break;
case CMD_CIRCLE_CENTER_RADIUS:
case CMD_CIRCLE_CENTER_POINT:
@@ -181,7 +180,9 @@ void place_points(struct drawing *drawing, double inputs[]) {
// printf("Rotate %f\n", current->arg3->value);
// printf("%f %f\n", current->arg2->line.norm[0], current->arg2->line.norm[1]);
- glm_vec2_rotate(current->arg2->line.norm, current->arg3->value, current->result.line.norm);
+ double value = current->arg3->value;
+ value = current->root == 0 ? value : -value;
+ glm_vec2_rotate(current->arg2->line.norm, value, current->result.line.norm);
// printf("%f %f\n", current->result.line.norm[0], current->result.line.norm[1]);
vec2 offset = {-current->arg1->point.pos[0], -current->arg1->point.pos[1]};
@@ -275,6 +276,7 @@ void place_points(struct drawing *drawing, double inputs[]) {
double theta;
// Align the two lines
theta = atan2(current->arg2->line.norm[1], current->arg2->line.norm[0]) - atan2(current->attachl->line.norm[1], current->attachl->line.norm[0]);
+ fprintf(stderr, "%f\n", theta / M_PI * 180.0);
mat3 transform;
glm_mat3_identity(transform);
@@ -322,7 +324,7 @@ void place_points(struct drawing *drawing, double inputs[]) {
}
fprintf(stderr, "W %f %f\n", origin->result.point.pos[0], origin->result.point.pos[1]);
- // transform_part(outer_object, NULL, transform);
+ transform_part(outer_object, NULL, transform);
}
}