-
Notifications
You must be signed in to change notification settings - Fork 0
/
mtr_init.c
84 lines (74 loc) · 2.08 KB
/
mtr_init.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
76
77
78
79
80
81
82
83
84
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mtr_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: proshchy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/10 14:14:11 by proshchy #+# #+# */
/* Updated: 2018/02/22 13:36:58 by proshchy ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void mtr_init_zero(t_mtr *mtr)
{
mtr->m1 = 0;
mtr->m2 = 0;
mtr->m3 = 0;
mtr->m4 = 0;
mtr->m5 = 0;
mtr->m6 = 0;
mtr->m7 = 0;
mtr->m8 = 0;
mtr->m9 = 0;
}
t_mtr *mtr_zoom_init(double val)
{
t_mtr *mtr;
if (!(mtr = ft_memalloc(sizeof(t_mtr))))
ft_error("malloc failed in mtr_zoom_init()");
mtr_init_zero(mtr);
mtr->m1 = val;
mtr->m5 = val;
mtr->m9 = val;
return (mtr);
}
t_mtr *mtr_init_x(double degr)
{
t_mtr *mtr;
if (!(mtr = ft_memalloc(sizeof(t_mtr))))
ft_putstr("malloc failed in mtr_init()");
mtr_init_zero(mtr);
mtr->m1 = 1;
mtr->m5 = cos(degr);
mtr->m6 = sin(degr);
mtr->m8 = -sin(degr);
mtr->m9 = cos(degr);
return (mtr);
}
t_mtr *mtr_init_y(double degr)
{
t_mtr *mtr;
if (!(mtr = ft_memalloc(sizeof(t_mtr))))
ft_error("malloc failed in mtr_init()");
mtr_init_zero(mtr);
mtr->m1 = cos(degr);
mtr->m3 = sin(degr);
mtr->m5 = 1;
mtr->m7 = -sin(degr);
mtr->m9 = cos(degr);
return (mtr);
}
t_mtr *mtr_init_z(double degr)
{
t_mtr *mtr;
if (!(mtr = ft_memalloc(sizeof(t_mtr))))
ft_error("malloc failed in mtr_init()");
mtr_init_zero(mtr);
mtr->m1 = cos(degr);
mtr->m2 = sin(degr);
mtr->m4 = -sin(degr);
mtr->m5 = cos(degr);
mtr->m9 = 1;
return (mtr);
}