-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform.c
More file actions
60 lines (52 loc) · 1.09 KB
/
transform.c
File metadata and controls
60 lines (52 loc) · 1.09 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
#include "fdf.h"
void translate(t_vector3f *p, t_vector3f move, int dir)
{
p->x += (move.x * dir);
p->y += (move.y * dir);
p->z += (move.z * dir);
}
void rot_x(t_vector3f *v, double ang, t_vector3f axis)
{
double tmp;
double cos_t;
double sin_t;
ang = ang * M_PI / 180.0;
(void)axis;
//translate(v, axis, -1);
sin_t = sin(ang);
cos_t = cos(ang);
tmp = v->y;
v->y = v->y * cos_t - v->z * sin_t;
v->z = tmp * sin_t + v->z * cos_t;
//translate(v, axis, 1);
}
void rot_y(t_vector3f *v, double ang, t_vector3f axis)
{
double tmp;
double cos_t;
double sin_t;
ang = ang * M_PI / 180.0;
(void)axis;
//translate(v, axis, -1);
sin_t = sin(ang);
cos_t = cos(ang);
tmp = v->z;
v->z = v->z * cos_t - v->x * sin_t;
v->x = tmp * sin_t + v->x * cos_t;
//translate(v, axis, 1);
}
void rot_z(t_vector3f *v, double ang, t_vector3f axis)
{
double tmp;
double cos_t;
double sin_t;
ang = ang * M_PI / 180.0;
(void)axis;
//translate(v, axis, -1);
sin_t = sin(ang);
cos_t = cos(ang);
tmp = v->x;
v->x = v->x * cos_t - v->y * sin_t;
v->y = tmp * sin_t + v->y * cos_t;
//translate(v, axis, 1);
}