-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrot_mtrx.c
More file actions
64 lines (57 loc) · 1.98 KB
/
rot_mtrx.c
File metadata and controls
64 lines (57 loc) · 1.98 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rot_mtrx.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ehugh-be <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/11 02:39:05 by ehugh-be #+# #+# */
/* Updated: 2019/01/14 20:20:58 by ehugh-be ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
t_mtrx *x_rot_mtrx(int x)
{
double xr;
t_mtrx *ret;
if (!(ret = ft_mtrx_init(4, 4, MTRX_DOUBLE)))
return (NULL);
xr = x * M_PI / 180;
((double *)ret->mtrx)[0] = 1;
((double *)ret->mtrx)[5] = cos(xr);
((double *)ret->mtrx)[6] = -sin(xr);
((double *)ret->mtrx)[9] = sin(xr);
((double *)ret->mtrx)[10] = cos(xr);
((double *)ret->mtrx)[15] = 1;
return (ret);
}
t_mtrx *y_rot_mtrx(int y)
{
double yr;
t_mtrx *ret;
if (!(ret = ft_mtrx_init(4, 4, MTRX_DOUBLE)))
return (NULL);
yr = y * M_PI / 180;
((double *)ret->mtrx)[0] = cos(yr);
((double *)ret->mtrx)[2] = sin(yr);
((double *)ret->mtrx)[5] = 1;
((double *)ret->mtrx)[8] = -sin(yr);
((double *)ret->mtrx)[10] = cos(yr);
((double *)ret->mtrx)[15] = 1;
return (ret);
}
t_mtrx *z_rot_mtrx(int z)
{
double zr;
t_mtrx *ret;
if (!(ret = ft_mtrx_init(4, 4, MTRX_DOUBLE)))
return (NULL);
zr = z * M_PI / 180;
((double *)ret->mtrx)[0] = cos(zr);
((double *)ret->mtrx)[1] = -sin(zr);
((double *)ret->mtrx)[4] = sin(zr);
((double *)ret->mtrx)[5] = cos(zr);
((double *)ret->mtrx)[10] = 1;
((double *)ret->mtrx)[15] = 1;
return (ret);
}