From bae93cba7a29023e074b16ad2bbcac0bcdf9716e Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 19 Mar 2018 16:03:04 +0100 Subject: [PATCH] use atan2() in Rotate_brush_0_5(). Remove warnings in MSVC++ acos() was replaced by atan2() in Rotate_brush_1_5() in commit 2d8c061e3220a592dd894ccde4ebbd80c6c16897 it was forgotten in Rotate_brush_0_5() ;) --- src/brush_ops.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/brush_ops.c b/src/brush_ops.c index 83101190..81b1cd76 100644 --- a/src/brush_ops.c +++ b/src/brush_ops.c @@ -950,7 +950,7 @@ void Rotate_brush_1_5(void) short old_x; short old_y; short prev_state; - float angle; + double angle; int dx,dy; short cursor_x,cursor_y; @@ -973,7 +973,7 @@ void Rotate_brush_1_5(void) { dx=cursor_x-Brush_rotation_center_X; dy=cursor_y-Brush_rotation_center_Y; - angle=M_2PI-atan2(dy,dx); + angle=M_2PI-atan2((double)dy,(double)dx); } if (Menu_is_visible) @@ -1045,8 +1045,7 @@ void Rotate_brush_0_5(void) { dx=cursor_x-Brush_rotation_center_X; dy=cursor_y-Brush_rotation_center_Y; - angle=acos(((float)dx)/sqrt((dx*dx)+(dy*dy))); - if (dy>0) angle=M_2PI-angle; + angle=M_2PI-atan2((double)dy, (double)dx); } if (Menu_is_visible) @@ -1071,13 +1070,13 @@ void Rotate_brush_0_5(void) computed_y=Brush_rotation_center_Y; switch (Key_ANSI) { - case '6': angle= 0.0 ; computed_x++; break; + case '6': angle= 0.0; computed_x++; break; case '9': angle=M_PI*0.25; computed_x++; computed_y--; break; - case '8': angle=M_PI*0.5 ; computed_y--; break; + case '8': angle=M_PI*0.5 ; computed_y--; break; case '7': angle=M_PI*0.75; computed_x--; computed_y--; break; - case '4': angle=M_PI ; computed_x--; break; + case '4': angle=M_PI ; computed_x--; break; case '1': angle=M_PI*1.25; computed_x--; computed_y++; break; - case '2': angle=M_PI*1.5 ; computed_y++; break; + case '2': angle=M_PI*1.5 ; computed_y++; break; case '3': angle=M_PI*1.75; computed_x++; computed_y++; break; default : angle_change=0;