-
Notifications
You must be signed in to change notification settings - Fork 0
/
perspective.c
75 lines (66 loc) · 1.85 KB
/
perspective.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
71
72
73
74
75
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* perspective.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-kadh <ael-kadh@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/12/16 06:32:14 by ael-kadh #+# #+# */
/* Updated: 2013/12/21 01:32:30 by ael-kadh ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
static t_mat perspective(t_mat per)
{
double f;
double zfar;
f = cotangente(60 / 2);
zfar = 1000;
per.m_a1 = 60 / 1.3333;
per.m_a2 = 0;
per.m_a3 = 0;
per.m_a4 = 0;
per.m_b1 = 0;
per.m_b2 = f;
per.m_b3 = 0;
per.m_b4 = 0;
per.m_c1 = 0;
per.m_c2 = 0;
per.m_c3 = (zfar + 1) / (1 - zfar);
per.m_c4 = (2 * zfar * 1) / (1 - zfar);
per.m_d1 = 0;
per.m_d2 = 0;
per.m_d3 = -1;
per.m_d4 = 0;
return (per);
}
t_vect *multi_napoli(t_env *e)
{
t_vect *tmp;
tmp = e->v;
while (tmp)
{
tmp->v_x = ((square(2) / (float) 2) *
(tmp->v_x - tmp->v_y)) + e->nb_c / 2;
tmp->v_y = (square((float) 2 / (float) 3) * (- tmp->v_z) -
((float) 1 / square(6)) * (tmp->v_x + tmp->v_y) + e->nb_l / 2);
tmp = tmp->next;
}
return (e->v);
}
t_vect *multi_perspective(t_vect *v)
{
t_vect *tmp;
t_mat per;
int i;
i = 0;
tmp = v;
while (tmp)
{
per = perspective(per);
tmp = multiplication(per, tmp);
tmp = tmp->next;
i++;
}
return (v);
}