feat: project skeleton, core types and math with transform tests

This commit is contained in:
Martino Ferrari committed 2026-09-27 20:54:19 +02:00
1 parent e4051bc6b5
commit 8a7e9e97f8
21 files changed
+515 -2

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#pragma once
#include <plot/core/types.hpp>
namespace plot::math {
/// Column-major 3x3 matrix of `f32`, the layout OpenGL expects for `mat3`
/// uniforms.
struct Mat3 {
f32 m[9] = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
static constexpr Mat3 identity() noexcept { return Mat3{}; }
/// Column-major product `(*this) * rhs`.
constexpr Mat3 operator*(const Mat3& rhs) const noexcept {
Mat3 out{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
for (usize col = 0; col < 3; ++col) {
for (usize row = 0; row < 3; ++row) {
f32 acc = 0.0f;
for (usize k = 0; k < 3; ++k) acc += m[k * 3 + row] * rhs.m[col * 3 + k];
out.m[col * 3 + row] = acc;
}
}
return out;
}
};
} // namespace plot::math
namespace plot {
using math::Mat3;
}