-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed rotation logic, pi is calculated by acos(-1) and the input ar…
…gument of rotation is degree
- Loading branch information
1 parent
1b44e10
commit c53eed0
Showing
1 changed file
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* 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; | ||
} |