-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmath_helper.c
41 lines (35 loc) · 1.34 KB
/
math_helper.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* math_helper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahamdaou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/07 12:48:34 by ahamdaou #+# #+# */
/* Updated: 2020/12/28 09:55:07 by ahamdaou ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
float normalize_angle(float angle)
{
angle = remainder(angle, (2 * M_PI));
if (angle < 0)
angle = (2 * M_PI) + angle;
return (angle);
}
float distance_between_points(t_point p1, t_point p2)
{
float result;
result = sqrt(
(p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
return (result);
}
float f_mod(float a, float b)
{
return (a - (floor(a / b) * b));
}
void setpoint(t_point *p, float x, float y)
{
p->x = x;
p->y = y;
}