-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3DFUNC.C
74 lines (58 loc) · 1.64 KB
/
3DFUNC.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
/* 3dfunc.c - transformation functions */
#include "structs.h"
void rotate_x(MODEL *model, double cosine, double sine)
{
register int vertex;
double y,z;
for (vertex = 0; vertex < model->vertices; vertex++)
{
y = model->world[vertex].y;
z = model->world[vertex].z;
model->world[vertex].y = y*cosine - z*sine;
model->world[vertex].z = y*sine + z*cosine;
}
}
void rotate_y(MODEL *model, double cosine, double sine)
{
register int vertex;
double x,z;
for (vertex = 0; vertex < model->vertices; vertex++)
{
x = model->world[vertex].x;
z = model->world[vertex].z;
model->world[vertex].x = x*cosine - z*sine;
model->world[vertex].z = x*sine + z*cosine;
}
}
void rotate_z(MODEL *model, double cosine, double sine)
{
register int vertex;
double x,y;
for (vertex = 0; vertex < model->vertices; vertex++)
{
x = model->world[vertex].x;
y = model->world[vertex].y;
model->world[vertex].x = x*cosine - y*sine;
model->world[vertex].y = x*sine + y*cosine;
}
}
void translate(MODEL *model, double x, double y, double z)
{
register int vertex;
for (vertex = 0; vertex < model->vertices; vertex++)
{
model->world[vertex].x += x;
model->world[vertex].y += y;
model->world[vertex].z += z;
}
}
void scale(MODEL *model, double scale_factor)
{
register int vertex;
for (vertex = 0; vertex < model->vertices; vertex++)
{
model->world[vertex].x *= scale_factor;
model->world[vertex].y *= scale_factor;
model->world[vertex].z *= scale_factor;
}
}