-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmax_min_xy.c
93 lines (83 loc) · 1.88 KB
/
max_min_xy.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* max_min_xy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: taehkwon <taehkwon@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 01:14:03 by taehkwon #+# #+# */
/* Updated: 2023/07/27 19:51:08 by taehkwon ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void max_min_xy(t_map *map)
{
map->max_x = find_max_x(map);
map->max_y = find_max_y(map);
map->min_x = find_min_x(map);
map->min_y = find_min_y(map);
}
double find_max_x(t_map *map)
{
double max;
int i;
max = -999999999;
i = 0;
while (i < map->width * map->height)
{
if (map->p_map[i].x > max)
{
max = map->p_map[i].x;
}
i++;
}
return (max);
}
double find_max_y(t_map *map)
{
double max;
int i;
max = -999999999;
i = 0;
while (i < map->width * map->height)
{
if (map->p_map[i].y > max)
{
max = map->p_map[i].y;
}
i++;
}
return (max);
}
double find_min_x(t_map *map)
{
double min;
int i;
min = 999999999;
i = 0;
while (i < map->width * map->height)
{
if (map->p_map[i].x < min)
{
min = map->p_map[i].x;
}
i++;
}
return (min);
}
double find_min_y(t_map *map)
{
double min;
int i;
min = 999999999;
i = 0;
while (i < map->width * map->height)
{
if (map->p_map[i].y < min)
{
min = map->p_map[i].y;
}
i++;
}
return (min);
}