From b20b4531c477b1a3c7a6c1c461f5fc4eebcdaebc Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Fri, 22 Dec 2023 01:38:33 -0800 Subject: [PATCH] 2-pt persp: mend vertical line direction flip --- magic/src/n_pt_persp.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/magic/src/n_pt_persp.c b/magic/src/n_pt_persp.c index 5792b2b1c..bb4071c1e 100644 --- a/magic/src/n_pt_persp.c +++ b/magic/src/n_pt_persp.c @@ -448,12 +448,6 @@ void n_pt_persp_drag(magic_api * api, int which, x1, y1, x2, y2, 2, n_pt_persp_line_xor_callback); } - -/* - api->line((void *) api, which, canvas, NULL, - x, y, a2_pt_x[i], a2_pt_y[i], 5, - n_pt_persp_line_xor_callback); -*/ } } else if (which == TOOL_3PT_DRAW) { /* 3-point perspective - draw */ @@ -564,9 +558,7 @@ void n_pt_persp_work(magic_api * api, int which, x2 = line_start_x + cos(a2_valid_angle[best_angle_idx]) * 1000; y2 = line_start_y + sin(a2_valid_angle[best_angle_idx]) * 1000; -// printf("angle #%d (%d)\n", best_angle_idx, (int) (a2_valid_angle[best_angle_idx] * 180.0 / M_PI)); - - if (x2 != x1) { + if (abs(x2 - x1) >= 2) { slope = ((float) y2 - (float) y1) / ((float) x2 - (float) x1); x2 = x; y2 = line_start_y + (slope * (x - line_start_x)); @@ -579,9 +571,8 @@ void n_pt_persp_work(magic_api * api, int which, x2 = ((y - line_start_y) / slope) + line_start_x; } } - /* FIXME: Sometimes the line goes off in the wrong direction! */ } else { - x2 = x; + x2 = x1; y2 = y; } } else if (which == TOOL_3PT_DRAW) {