-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotation.c
More file actions
60 lines (50 loc) · 1.72 KB
/
rotation.c
File metadata and controls
60 lines (50 loc) · 1.72 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
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotation.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gemerald <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/23 18:02:40 by gemerald #+# #+# */
/* Updated: 2019/11/23 18:03:31 by gemerald ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void rot_x(int *y, int *z, double alpha)
{
int tmp_y;
tmp_y = *y;
*y = (tmp_y) * cos(alpha) + *z * sin(alpha);
*z = -(tmp_y) * sin(alpha) + *z * cos(alpha);
}
void rot_y(int *x, int *z, double beta)
{
int tmp_x;
tmp_x = *x;
*x = (tmp_x) * cos(beta) + *z * sin(beta);
*z = -(tmp_x) * sin(beta) + *z * cos(beta);
}
void rot_z(int *x, int *y, double tetta)
{
int tmp_x;
int tmp_y;
tmp_x = *x;
tmp_y = *y;
*x = (tmp_x) * cos(tetta) - (tmp_y) * sin(tetta);
*y = (tmp_x) * sin(tetta) + (tmp_y) * cos(tetta);
}
int abso_lut(int a, int b)
{
int abs;
abs = b - a;
if (abs < 0)
abs = -abs;
return (abs);
}
void init_var_draw(t_pix *delta, t_pix *sign, t_pix start, t_pix end)
{
delta->x = abso_lut(start.x, end.x);
delta->y = abso_lut(start.y, end.y);
sign->x = start.x < end.x ? 1 : -1;
sign->y = start.y < end.y ? 1 : -1;
}