diff --git a/srcs/vector/vector_2.c b/srcs/vector/vector_2.c index 1ec1215..03dc592 100644 --- a/srcs/vector/vector_2.c +++ b/srcs/vector/vector_2.c @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/27 13:33:30 by tsuchen #+# #+# */ -/* Updated: 2024/08/27 14:28:36 by tsuchen ### ########.fr */ +/* Updated: 2024/08/27 15:32:46 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -51,9 +51,13 @@ void vec_rotate(t_vec *vec, double angle) { double new_x; double new_y; + double pi; + double angle_r; - new_x = vec->x * cos(angle) - vec->y * sin(angle); - new_y = vec->x * sin(angle) + vec->y * cos(angle); + pi = acos(-1); + angle_r = angle * pi / 180; + new_x = vec->x * cos(angle_r) - vec->y * sin(angle_r); + new_y = vec->x * sin(angle_r) + vec->y * cos(angle_r); vec->x = new_x; vec->y = new_y; }