diff --git a/include/blt/math/matrix.h b/include/blt/math/matrix.h index 874e4c0..c47b8eb 100644 --- a/include/blt/math/matrix.h +++ b/include/blt/math/matrix.h @@ -228,6 +228,16 @@ namespace blt { return ret; } + template + inline vec4 operator*(const mat4x4& left, const vec& right){ + vec4 ret{0,0,0,0}; + + for (int i = 0; i < size; i++) + ret[i] = (float)right[i]; + + return left * ret; + } + // multiplies the const c with each element in the mat4x4 v inline mat4x4 operator*(float c, const mat4x4& v) { mat4x4 mat{}; diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 7936dc7..603add2 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -5,20 +5,11 @@ #include "profiling_tests.h" #include "nbt_tests.h" #include "queue_tests.h" +#include "blt/math/vectors.h" +#include "blt/math/matrix.h" #include int main() { - - int data = 0; - int index = 2; - data = data | index << (32 - 2); - auto fdata = *reinterpret_cast(&data); - - auto back_to_int = *reinterpret_cast(&fdata); - - std::string bits = std::bitset<32>((unsigned long long) back_to_int).to_string(); - std::cout << bits << "\n"; - return 0; binaryTreeTest(); run_logging(); @@ -36,5 +27,19 @@ int main() { test_queues(); + blt::vec4 v{2, 5, 1, 8}; + blt::mat4x4 m{}; + m.m(0,0, 1); + m.m(0,2, 2); + m.m(1, 1, 3); + m.m(1, 3, 4); + m.m(2, 2, 5); + m.m(3, 0, 6); + m.m(3, 3, 7); + + auto result = m * v; + + std::cout << result.x() << " " << result.y() << " " << result.z() << " " << result.w() << std::endl; + return 0; } \ No newline at end of file