-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3D.h
112 lines (72 loc) · 1.86 KB
/
3D.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ThreeD_H
#define ThreeD_H
#define ROW 4
#define COL 4
typedef struct /* structure definitions */
{
float mat[ROW][COL];
} matrix_unit;
typedef struct
{
float i;
float j;
float k;
} Vector;
typedef struct
{
float x;
float y;
float z;
float r;
float g;
float b;
} Vertex_unit;
typedef struct
{
float mat41[ROW];
} matrix41;
extern const matrix_unit I;
//extern matrix_unit ini;
extern matrix_unit *stack[50]; /* array of pointers to act as a stack */
extern float Near, Far;
extern int width, height;
extern int top; /* points to top of the stack */
extern int perspflag;
extern matrix_unit orth; /* global ortho and perspective matrices */
/* to be used in Vertex3f */
extern matrix_unit perspect;
void draw_line(float, float, float, float);
int near_far_clip(float, float, float *, float *, float *, float *,
float *, float *);
void gtLookAt( float fx, float fy, float fz, float atx, float aty,
float atz, float upx, float upy, float upz);
void gtVertex3f(float x, float y, float z);
void Cross(Vector *x, Vector *y, Vector *z);
void Unitvec(float x, float y, float z, Vector *vec);
int Mult_end(matrix_unit *M, matrix41 *V, matrix41 *result);
int Mult_mat(matrix_unit *left, matrix_unit *right, matrix_unit *result);
int Copy_mat(const matrix_unit *from, matrix_unit *to);
//extra matrix math support for assignment5
typedef struct
{
float mat[3][3];
} mat3;
typedef struct
{
float mat[3];
} vec3;
float determinant(mat3 matrix);
float vec3Mul(vec3 a, vec3 b);
vec3 vec3Cross(vec3 a, vec3 b);
vec3 vec3NumMul(float num, vec3 a);
vec3 vec3Add(vec3 a, vec3 b);
vec3 vec3Minus(vec3 a, vec3 b);
vec3 vec3Div(vec3 a, vec3 b);
vec3 normal(vec3 a);
#endif
#ifdef __cplusplus
}
#endif