-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_util.c
43 lines (37 loc) · 1.36 KB
/
math_util.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* math_util.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/16 19:23:15 by hgrissen #+# #+# */
/* Updated: 2021/02/11 16:09:00 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
float d2r(float ang)
{
return (M_PI / 180) * ang;
}
float normalize_ang(float ang)
{
ang = fmod(ang, (2 * M_PI));
if (ang < 0)
ang += (2 * M_PI);
return (ang);
}
float dis_pts(float x1, float y1, float x2, float y2)
{
return (sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}
float clamp_percent(float percent)
{
percent = (percent < 0) ? 0 : percent;
percent = (percent > 1) ? 1 : percent;
return (percent);
}
float deg(float x)
{
return ((180 / M_PI) * x);
}