|
|
|
@ -9,6 +9,8 @@
|
|
|
|
|
#include <libgba-sprite-engine/math.h>
|
|
|
|
|
#include <libgba-sprite-engine/vectorfx.h>
|
|
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
|
|
#ifdef CODE_COMPILED_AS_PART_OF_TEST
|
|
|
|
|
#include <libgba-sprite-engine/gba/tonc_math_stub.h>
|
|
|
|
|
#else
|
|
|
|
@ -19,6 +21,13 @@ class MatrixFx {
|
|
|
|
|
private:
|
|
|
|
|
FIXED m[MATRIX_DIMENSION];
|
|
|
|
|
|
|
|
|
|
inline std::string mstr(int index) {
|
|
|
|
|
char buffer[30];
|
|
|
|
|
snprintf(buffer, 30, "%4.3f", rnd(fx2float(m[index])));
|
|
|
|
|
std::string strObj4(buffer);
|
|
|
|
|
return strObj4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
inline static MatrixFx zero() { return MatrixFx(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); }
|
|
|
|
@ -96,6 +105,18 @@ public:
|
|
|
|
|
m[14] = m43;
|
|
|
|
|
m[15] = m44;
|
|
|
|
|
}
|
|
|
|
|
std::string to_string_m1() {
|
|
|
|
|
return "(" + mstr(0) + "," + mstr(1) + "," + mstr(2) + "," + mstr(3) +")";
|
|
|
|
|
}
|
|
|
|
|
std::string to_string_m2() {
|
|
|
|
|
return "(" + mstr(4) + "," + mstr(5) + "," + mstr(6) + "," + mstr(7) +")";
|
|
|
|
|
}
|
|
|
|
|
std::string to_string_m3() {
|
|
|
|
|
return "(" + mstr(8) + "," + mstr(9) + "," + mstr(10) + "," + mstr(11) +")";
|
|
|
|
|
}
|
|
|
|
|
std::string to_string_m4() {
|
|
|
|
|
return "(" + mstr(12) + "," + mstr(13) + "," + mstr(14) + "," + mstr(15) +")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline static VectorFx transformCoordinates(const VectorFx &vector, const MatrixFx &transformation) {
|
|
|
|
|
FIXED x = fxmul(vector.x(), transformation.mAt(0)) + fxmul(vector.y(), transformation.mAt(4)) + fxmul(vector.z(), transformation.mAt(8) + transformation.mAt(12));
|
|
|
|
|