-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_rotation.c
56 lines (48 loc) · 1.66 KB
/
map_rotation.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_rotation.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbaela <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/25 11:31:10 by lbaela #+# #+# */
/* Updated: 2021/10/27 16:27:42 by lbaela ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
static void x_rotation(t_point *this, double xx)
{
int y;
int z;
y = this->y;
z = this->z;
this->y = (int)(y * cos(xx) + z * sin(xx));
this->z = (int)(-y * sin(xx) + z * cos(xx));
}
static void y_rotation(t_point *this, double yy)
{
int x;
int z;
x = this->x;
z = this->z;
this->x = (int)(x * cos(yy) + z * sin(yy));
this->z = (int)(-x * sin(yy) + z * cos(yy));
}
static void z_rotation(t_point *this, double zz)
{
int x;
int y;
x = this->x;
y = this->y;
this->x = (int)(x * cos(zz) - y * sin(zz));
this->y = (int)(x * sin(zz) + y * cos(zz));
}
void rotate_point(t_point *this, t_fdf *fdf)
{
if (fdf->camera.zz)
z_rotation(this, fdf->camera.zz);
if (fdf->camera.xx)
x_rotation(this, fdf->camera.xx);
if (fdf->camera.yy)
y_rotation(this, fdf->camera.yy);
}