-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotation.c
More file actions
58 lines (49 loc) · 1.69 KB
/
Copy pathrotation.c
File metadata and controls
58 lines (49 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotation.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rrollin <rrollin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/09 16:08:38 by rrollin #+# #+# */
/* Updated: 2022/05/14 14:17:10 by rrollin ### ########.fr */
/* */
/* ************************************************************************** */
#include"fdf.h"
void ft_rotate_x(t_point *point, float theta)
{
float tmp;
tmp = cos(theta) * point->y - sin(theta) * point->z;
point->z = sin(theta) * point->y + cos(theta) * point->z;
point->y = tmp;
}
void ft_rotate_y(t_point *point, float theta)
{
float tmp;
tmp = cos(theta) * point->x + sin(theta) * point->z;
point->z = -sin(theta) * point->x + cos(theta) * point->z;
point->x = tmp;
}
void ft_rotate_z(t_point *point, float theta)
{
float tmp;
tmp = cos(theta) * point->x - sin(theta) * point->y;
point->y = sin(theta) * point->x + cos(theta) * point->y;
point->x = tmp;
}
void ft_rotate(t_vars *vars, float theta, void (*rotation)(t_point*, float))
{
int i;
int j;
i = 0;
while (vars->matrix[i])
{
j = 0;
while (vars->matrix[i][j])
{
rotation(vars->matrix[i][j], theta);
j++;
}
i++;
}
}