-
Notifications
You must be signed in to change notification settings - Fork 0
/
math.bt
423 lines (376 loc) · 8.81 KB
/
math.bt
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
// ==== Structures =====================================================================================================
typedef struct // Matrix2x2
{
float m11; float m12;
float m21; float m22;
} Matrix2x2 <read=Matrix2x2Read, write=Matrix2x2Write>;
typedef struct // Matrix2x3
{
float m11; float m12; float m13;
float m21; float m22; float m23;
} Matrix2x3 <read=Matrix2x3Read, write=Matrix2x3Write>;
typedef struct // Matrix2x4
{
float m11; float m12; float m13; float m14;
float m21; float m22; float m23; float m24;
} Matrix2x4 <read=Matrix2x4Read, write=Matrix2x4Write>;
typedef struct // Matrix3x2
{
float m11; float m12;
float m21; float m22;
float m31; float m32;
} Matrix3x2 <read=Matrix3x2Read, write=Matrix3x2Write>;
typedef struct // Matrix3x3
{
float m11; float m12; float m13;
float m21; float m22; float m23;
float m31; float m32; float m33;
} Matrix3x3 <read=Matrix3x3Read, write=Matrix3x3Write>;
typedef struct // Matrix3x4
{
float m11; float m12; float m13; float m14;
float m21; float m22; float m23; float m24;
float m31; float m32; float m33; float m34;
} Matrix3x4 <read=Matrix3x4Read, write=Matrix3x4Write>;
typedef struct // Matrix4x2
{
float m11; float m12;
float m21; float m22;
float m31; float m32;
float m41; float m42;
} Matrix4x2 <read=Matrix4x2Read, write=Matrix4x2Write>;
typedef struct // Matrix4x3
{
float m11; float m12; float m13;
float m21; float m22; float m23;
float m31; float m32; float m33;
float m41; float m42; float m43;
} Matrix4x3 <read=Matrix4x3Read, write=Matrix4x3Write>;
typedef struct // Matrix4x4
{
float m11; float m12; float m13; float m14;
float m21; float m22; float m23; float m24;
float m31; float m32; float m33; float m34;
float m41; float m42; float m43; float m44;
} Matrix4x4 <read=Matrix4x4Read, write=Matrix4x4Write>;
typedef struct // Vector2
{
int x; int y;
} Vector2 <read=Vector2Read, write=Vector2Write>;
typedef struct // Vector2B
{
byte x; byte y;
} Vector2B <read=Vector2BRead, write=Vector2BWrite>;
typedef struct // Vector2F
{
float x; float y;
} Vector2F <read=Vector2FRead, write=Vector2FWrite>;
typedef struct // Vector2U
{
uint x; uint y;
} Vector2U <read=Vector2URead, write=Vector2UWrite>;
typedef struct // Vector3
{
int x; int y; int z;
} Vector3 <read=Vector3Read, write=Vector3Write>;
typedef struct // Vector3B
{
byte x; byte y; byte z;
} Vector3B <read=Vector3BRead, write=Vector3BWrite>;
typedef struct // Vector3F
{
float x; float y; float z;
} Vector3F <read=Vector3FRead, write=Vector3FWrite>;
typedef struct // Vector3U
{
uint x; uint y; uint z;
} Vector3U <read=Vector3URead, write=Vector3UWrite>;
typedef struct // Vector4
{
int x; int y; int z; int w;
} Vector4 <read=Vector4Read, write=Vector4Write>;
typedef struct // Vector4B
{
byte x; byte y; byte z; byte w;
} Vector4B <read=Vector4BRead, write=Vector4BWrite>;
typedef struct // Vector4F
{
float x; float y; float z; float w;
} Vector4F <read=Vector4FRead, write=Vector4FWrite>;
typedef struct // Vector4U
{
uint x; uint y; uint z; uint w;
} Vector4U <read=Vector4URead, write=Vector4UWrite>;
// ==== Template Methods ===============================================================================================
void FAlign(byte alignment)
{
local int bytesToSkip <hidden=true> = (-FTell() % alignment + alignment) % alignment;
while (bytesToSkip--)
{
byte padding <fgcolor=0x808080, hidden=true>;
}
}
string Matrix2x2Read(Matrix2x2 &v)
{
string s;
SPrintf(s, "((%f, %f), (%f, %f))",
v.m11, v.m12,
v.m21, v.m22);
return s;
}
void Matrix2x2Write(Matrix2x2 &v, string s)
{
SScanf(s, "((%f, %f), (%f, %f))",
v.m11, v.m12,
v.m21, v.m22);
}
string Matrix2x3Read(Matrix2x3 &v)
{
string s;
SPrintf(s, "((%f, %f, %f), (%f, %f, %f))",
v.m11, v.m12, v.m13,
v.m21, v.m22, v.m23);
return s;
}
void Matrix2x3Write(Matrix2x3 &v, string s)
{
SScanf(s, "((%f, %f, %f), (%f, %f, %f))",
v.m11, v.m12, v.m13,
v.m21, v.m22, v.m23);
}
string Matrix2x4Read(Matrix2x4 &v)
{
string s;
SPrintf(s, "((%f, %f, %f, %f), (%f, %f, %f, %f))",
v.m11, v.m12, v.m13, v.m14,
v.m21, v.m22, v.m23, v.m24);
return s;
}
void Matrix2x4Write(Matrix2x4 &v, string s)
{
SScanf(s, "((%f, %f, %f, %f), (%f, %f, %f, %f))",
v.m11, v.m12, v.m13, v.m14,
v.m21, v.m22, v.m23, v.m24);
}
string Matrix3x2Read(Matrix3x2 &v)
{
string s;
SPrintf(s, "((%f, %f), (%f, %f), (%f, %f))",
v.m11, v.m12,
v.m21, v.m22,
v.m31, v.m31);
return s;
}
void Matrix3x2Write(Matrix3x2 &v, string s)
{
SScanf(s, "((%f, %f), (%f, %f), (%f, %f))",
v.m11, v.m12,
v.m21, v.m22,
v.m31, v.m31);
}
string Matrix3x3Read(Matrix3x3 &v)
{
string s;
SPrintf(s, "((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))",
v.m11, v.m12, v.m13,
v.m21, v.m22, v.m23,
v.m31, v.m32, v.m33);
return s;
}
void Matrix3x3Write(Matrix3x3 &v, string s)
{
SScanf(s, "((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))",
v.m11, v.m12, v.m13,
v.m21, v.m22, v.m23,
v.m31, v.m32, v.m33);
}
string Matrix3x4Read(Matrix3x4 &v)
{
string s;
SPrintf(s, "((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))",
v.m11, v.m12, v.m13, v.m14,
v.m21, v.m22, v.m23, v.m24,
v.m31, v.m32, v.m33, v.m34);
return s;
}
void Matrix3x4Write(Matrix3x4 &v, string s)
{
SScanf(s, "((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))",
v.m11, v.m12, v.m13, v.m14,
v.m21, v.m22, v.m23, v.m24,
v.m31, v.m32, v.m33, v.m34);
}
string Matrix4x2Read(Matrix4x2 &v)
{
string s;
SPrintf(s, "((%f, %f), (%f, %f), (%f, %f), (%f, %f))",
v.m11, v.m12,
v.m21, v.m22,
v.m31, v.m32,
v.m41, v.m42);
return s;
}
void Matrix4x2Write(Matrix4x2 &v, string s)
{
SScanf(s, "((%f, %f), (%f, %f), (%f, %f), (%f, %f))",
v.m11, v.m12,
v.m21, v.m22,
v.m31, v.m32,
v.m41, v.m42);
}
string Matrix4x3Read(Matrix4x3 &v)
{
string s;
SPrintf(s, "((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))",
v.m11, v.m12, v.m13,
v.m21, v.m22, v.m23,
v.m31, v.m32, v.m33,
v.m41, v.m42, v.m43);
return s;
}
void Matrix4x3Write(Matrix4x3 &v, string s)
{
SScanf(s, "((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))",
v.m11, v.m12, v.m13,
v.m21, v.m22, v.m23,
v.m31, v.m32, v.m33,
v.m41, v.m42, v.m43);
}
string Matrix4x4Read(Matrix4x4 &v)
{
string s;
SPrintf(s, "((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))",
v.m11, v.m12, v.m13, v.m14,
v.m21, v.m22, v.m23, v.m24,
v.m31, v.m32, v.m33, v.m34,
v.m41, v.m42, v.m43, v.m44);
return s;
}
void Matrix4x4Write(Matrix4x4 &v, string s)
{
SScanf(s, "((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))",
v.m11, v.m12, v.m13, v.m14,
v.m21, v.m22, v.m23, v.m24,
v.m31, v.m32, v.m33, v.m34,
v.m41, v.m42, v.m43, v.m44);
}
string Vector2Read(Vector2 &v)
{
string s;
SPrintf(s, "(%d, %d)", v.x, v.y);
return s;
}
void Vector2Write(Vector2 &v, string s)
{
SScanf(s, "(%d, %d)", v.x, v.y);
}
string Vector2BRead(Vector2B &v)
{
string s;
SPrintf(s, "(%u, %u)", v.x, v.y);
return s;
}
void Vector2BWrite(Vector2B &v, string s)
{
SScanf(s, "(%u, %u)", v.x, v.y);
}
string Vector2FRead(Vector2F &v)
{
string s;
SPrintf(s, "(%f, %f)", v.x, v.y);
return s;
}
void Vector2FWrite(Vector2F &v, string s)
{
SScanf(s, "(%f, %f)", v.x, v.y);
}
string Vector2URead(Vector2F &v)
{
string s;
SPrintf(s, "(%u, %u)", v.x, v.y);
return s;
}
void Vector2UWrite(Vector2F &v, string s)
{
SScanf(s, "(%u, %u)", v.x, v.y);
}
string Vector3Read(Vector3 &v)
{
string s;
SPrintf(s, "(%d, %d, %d)", v.x, v.y, v.z);
return s;
}
void Vector3Write(Vector3 &v, string s)
{
SScanf(s, "(%d, %d, %d)", v.x, v,y, v.z);
}
string Vector3BRead(Vector3B &v)
{
string s;
SPrintf(s, "(%u, %u, %u)", v.x, v.y, v.z);
return s;
}
void Vector3BWrite(Vector3B &v, string s)
{
SScanf(s, "(%u, %u, %u)", v.x, v,y, v.z);
}
string Vector3FRead(Vector3F &v)
{
string s;
SPrintf(s, "(%f, %f, %f)", v.x, v.y, v.z);
return s;
}
void Vector3FWrite(Vector3F &v, string s)
{
SScanf(s, "(%f, %f, %f)", v.x, v,y, v.z);
}
string Vector3URead(Vector3U &v)
{
string s;
SPrintf(s, "(%u, %u, %u)", v.x, v.y, v.z);
return s;
}
void Vector3UWrite(Vector3U &v, string s)
{
SScanf(s, "(%u, %u, %u)", v.x, v,y, v.z);
}
string Vector4Read(Vector4 &v)
{
string s;
SPrintf(s, "(%d, %d, %d, %d)", v.x, v.y, v.z, v.w);
return s;
}
void Vector4Write(Vector4 &v, string s)
{
SScanf(s, "(%d, %d, %d, %d)", v.x, v.y, v.z, v.w);
}
string Vector4BRead(Vector4B &v)
{
string s;
SPrintf(s, "(%u, %u, %u, %u)", v.x, v.y, v.z, v.w);
return s;
}
void Vector4BWrite(Vector4B &v, string s)
{
SScanf(s, "(%u, %u, %u, %u)", v.x, v.y, v.z, v.w);
}
string Vector4FRead(Vector4F &v)
{
string s;
SPrintf(s, "(%f, %f, %f, %f)", v.x, v.y, v.z, v.w);
return s;
}
void Vector4FWrite(Vector4F &v, string s)
{
SScanf(s, "(%f, %f, %f, %f)", v.x, v.y, v.z, v.w);
}
string Vector4URead(Vector4U &v)
{
string s;
SPrintf(s, "(%u, %u, %u, %u)", v.x, v.y, v.z, v.w);
return s;
}
void Vector4UWrite(Vector4U &v, string s)
{
SScanf(s, "(%u, %u, %u, %u)", v.x, v.y, v.z, v.w);
}