-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_utils2.c
58 lines (51 loc) · 1.55 KB
/
set_utils2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: shongou <shongou@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 23:34:40 by shongou #+# #+# */
/* Updated: 2023/01/04 23:34:42 by shongou ### ########.fr */
/* */
/* ************************************************************************** */
#include "minirt.h"
double set_fov(char *str, int *err_flag)
{
double fov;
if (!valid_float(str))
{
*err_flag |= INVALID_FOV;
return (0);
}
fov = atod(str);
if (fov < 0.0 || 180.0 < fov)
*err_flag |= INVALID_FOV;
return (fov);
}
double set_ratio(char *str, int *err_flag)
{
double ratio;
if (!valid_float(str))
{
*err_flag |= INVALID_RATIO;
return (0);
}
ratio = atod(str);
if (ratio < 0.0 || 1.0 < ratio)
*err_flag |= INVALID_RATIO;
return (ratio);
}
double set_size(char *str, int *err_flag)
{
double size;
if (!valid_float(str))
{
*err_flag |= INVALID_SIZE;
return (0);
}
size = atod(str);
if (size <= 0.0)
*err_flag |= INVALID_SIZE;
return (size);
}