-
Notifications
You must be signed in to change notification settings - Fork 0
/
limits.c
68 lines (62 loc) · 1.79 KB
/
limits.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
57
58
59
60
61
62
63
64
65
66
67
68
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* limits.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rrollin <rrollin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/09 17:57:27 by rrollin #+# #+# */
/* Updated: 2022/05/09 18:24:19 by rrollin ### ########.fr */
/* */
/* ************************************************************************** */
#include"fdf.h"
void ft_check_limits(t_point *point, int *limits)
{
if (point->x < limits[0])
limits[0] = point->x;
if (point->x > limits[1])
limits[1] = point->x;
if (point->y < limits[2])
limits[2] = point->y;
if (point->y > limits[3])
limits[3] = point->y;
}
void ft_get_limits(t_vars *vars, int *limits)
{
int i;
int j;
limits[0] = vars->matrix[0][0]->x;
limits[1] = vars->matrix[0][0]->x;
limits[2] = vars->matrix[0][0]->y;
limits[3] = vars->matrix[0][0]->y;
i = 0;
while (vars->matrix[i])
{
j = 0;
if (!i)
j++;
while (vars->matrix[i][j])
{
ft_check_limits(vars->matrix[i][j], limits);
j++;
}
i++;
}
}
void ft_update_matrix(t_vars *vars, int *limits)
{
int i;
int j;
i = 0;
while (vars->matrix[i])
{
j = 0;
while (vars->matrix[i][j])
{
vars->matrix[i][j]->x -= (limits[1] - limits[0]) / 2;
vars->matrix[i][j]->y -= (limits[3] - limits[2]) / 2;
j++;
}
i++;
}
}