-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaping.c
70 lines (60 loc) · 1.69 KB
/
maping.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* maping.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ymoukhli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/11 19:52:42 by ymoukhli #+# #+# */
/* Updated: 2019/07/11 20:24:16 by ymoukhli ### ########.fr */
/* */
/* ************************************************************************** */
#include "rtv1.h"
void ft_light_pixel(t_params *init, t_val v, t_cam cam)
{
int i;
if (cam.x < 0 || cam.y < 0 || cam.y > HEIGHT || cam.x > WIDTH)
return ;
i = (cam.x * 4) + (cam.y * WIDTH * 4);
init->data[i] = (unsigned char)v.col.z;
init->data[i + 1] = (unsigned char)v.col.y;
init->data[i + 2] = (unsigned char)v.col.x;
}
float ft_map_x(int xx)
{
float x;
x = ((float)xx * (float)MAP_SIZE / WIDTH) - 0.5;
return (x);
}
float ft_map_y(int yy)
{
float y;
y = ((float)yy * (float)MAP_SIZE / HEIGHT) - 0.5;
return (y);
}
t_vect ft_init_cam(void)
{
t_vect v;
v.x = 0;
v.y = 0;
v.z = 0;
return (v);
}
float ft_min_posi(float t1, float t2)
{
if (t1 < t2)
{
if (t1 > 0)
return (t1);
else
return (t2);
}
else if (t1 > t2)
{
if (t2 > 0)
return (t2);
else
return (t1);
}
return (INFINIT);
}