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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#ifndef _MEIDOGTE_H
#define _MEIDOGTE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <meidogte_inline.h>
/**
* One degree = 4096
*/
#define ONE 4096
typedef struct {
short m[3][3];
int t[3];
} MATRIX;
typedef struct {
int vx, vy, vz;
} VECTOR;
typedef struct {
short vx, vy, vz, pad;
} SVECTOR;
typedef struct {
unsigned char r, g, b, cd;
} CVECTOR;
/**
* Initialize MeidoGTE library
*/
void InitGeom();
/**
* Integer sine function (4096 = 360 degrees)
* @param a Input
* @return Sine of input
*/
int isin(int a);
/**
* Integer cosine function (4096 = 360 degrees)
* @param a Input
* @return Cosine of input
*/
int icos(int a);
/**
* Higher precision integer sine function (131072 = 360 degrees)
* @param a Input
* @return Sine of input
*/
int hisin(int a);
/**
* Higher precision integer cosine function (131072 = 360 degrees)
* @param a Input
* @return Cosine of input
*/
int hicos(int a);
/**
* Save a constant rotation matrix in stack.
*/
void PushMatrix();
/**
* Reset a constant rotation matrix from stack.
*/
void PopMatrix();
/**
* Find rotation matrix from a rotation angle. (4096 = 360 degrees)
* @param r Rotation angle (input)
* @param m Rotation matrix (output)
* @return Pointer to m
*/
MATRIX *RotMatrix(SVECTOR *r, MATRIX *m);
/**
* Find rotation matrix from a rotation angle. (high-precision) (131072 = 360 degrees)
* @param r Rotation angle (input)
* @param m Rotation matrix (output)
* @return Pointer to m
*/
MATRIX *HiRotMatrix(VECTOR *r, MATRIX *m);
/**
* Give an amount of parallel transfer expressed by v to the matrix m.
* @param m Pointer to matrix (output)
* @param v Pointer to transfer vector (input)
* @return Pointer to m
*/
MATRIX *TransMatrix(MATRIX *m, VECTOR *r);
/**
* Scale m by v.
* @param m Pointer to matrix (output)
* @param v Pointer to scale vector (input)
* @return Pointer to m
*/
MATRIX *ScaleMatrix(MATRIX *m, VECTOR *s);
/**
* Multiply two matrices.
* @param m0 First matrix (result is saved here)
* @param m1 Second matrix
* @return Pointer to m0.
*/
MATRIX *MulMatrix(MATRIX *m0, MATRIX *m1);
/**
* Multiply two matrices.
* @param m0 First matrix
* @param m1 Second matrix
* @param m2 Output matrix
* @return Pointer to m2
*/
MATRIX *MulMatrix0(MATRIX *m0, MATRIX *m1, MATRIX *m2);
/**
* Make a composite coordinate transformation matrix.
* @param m0 First matrix
* @param m1 Second matrix
* @param m2 Output matrix
* @return Pointer to m2
*/
MATRIX *CompMatrixLV(MATRIX *v0, MATRIX *v1, MATRIX *v2);
/**
* Multiply a vector by a matrix.
* @param m Pointer to matrix to be multiplied
* @param v0 Pointer to vector (input)
* @param v1 Pointer to vector (output)
* @return Pointer to v1
*/
VECTOR *ApplyMatrixLV(MATRIX *m, VECTOR *v0, VECTOR *v1);
/**
* Normalize a vector.
* Warning: if ((v0->vx)^2 + (v1->vx)^2 +(v2->vx)^2) > 0x7FFFFFF,
* a processor exception will occur.
* @param v0 Pointer to vector (input)
* @param v1 Pointer to vector (output)
*/
void VectorNormalS(VECTOR *v0, SVECTOR *v1);
/**
* Return a vector, obtained by squaring each term of the vector v0, to v1.
* @param v0 Pointer to vector (input)
* @param v1 Pointer to vector (output)
*/
void Square0(VECTOR *v0, VECTOR *v1);
/**
* Square root
* @param a Input value
* @return Square root of input value
*/
int SquareRoot0(int a);
/**
* Square root
* @param a Input value in (0, 20, 12) format
* @return Square root of input value in (0, 20, 12) format
*/
int SquareRoot12(int a);
#ifdef __cplusplus
}
#endif
#endif // _MEIDOGTE_H
|