-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
executable file
·53 lines (45 loc) · 1.45 KB
/
utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fflores <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/02 18:43:42 by fflores #+# #+# */
/* Updated: 2020/11/02 18:43:43 by fflores ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int ft_min(int a, int b)
{
return ((a < b) ? a : b);
}
int ft_max(int a, int b)
{
return ((a > b) ? a : b);
}
int ft_numsize(int num)
{
int size;
size = 1;
while (num / 10)
{
num = num / 10;
size++;
}
return (size);
}
float normalize_angle(double angle)
{
double alpha;
alpha = angle;
while (alpha >= 2 * M_PI)
alpha = alpha - 2 * M_PI;
while (alpha < 0)
alpha = alpha + 2 * M_PI;
return ((float)alpha);
}
double calculate_distance(double x1, double y1, double x2, double y2)
{
return (sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}