-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstripe_it.c
53 lines (47 loc) · 1.82 KB
/
stripe_it.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stripe_it.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mpauw <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/21 16:11:17 by mpauw #+# #+# */
/* Updated: 2018/06/26 11:49:36 by mpauw ### ########.fr */
/* */
/* ************************************************************************** */
#include "rt.h"
static t_material handle_plane(t_object o, t_3v dif)
{
double d_1;
double d_2;
double tmp_size;
tmp_size = o.pattern.size;
d_1 = fmod(fabs(dif.v[0] + dif.v[1] * o.pattern.os_1) + tmp_size / 2,
o.pattern.distance);
d_2 = fmod(fabs(dif.v[0] + dif.v[1] * o.pattern.os_2) + tmp_size / 2,
o.pattern.distance);
if (d_1 < tmp_size || d_2 < tmp_size)
return (o.m2);
return (o.m);
}
static t_material handle_cyl_cone(t_object o, t_3v angle, t_3v dif)
{
double d_1;
double tmp_size;
tmp_size = o.pattern.size;
d_1 = fmod(fabs(angle.v[2] + dif.v[2] * o.pattern.os_1 / 100.0) +
tmp_size / 2, o.pattern.distance);
if (d_1 < tmp_size)
return (o.m2);
return (o.m);
}
t_material stripe_it(t_object o, t_3v angle, t_3v dif)
{
if (o.type == 0)
return (handle_plane(o, dif));
else if (o.type == 1)
return (handle_cyl_cone(o, angle, dif));
else if (o.type == 2 || o.type == 3)
return (handle_cyl_cone(o, angle, dif));
return (o.m);
}