1
0
Files
BasaltMeter/BasaltPresenter/Shared/basalt/math.hpp

42 lines
1012 B
C++
Raw Normal View History

2026-01-06 16:27:19 +08:00
#pragma once
#include <stdexcept>
2026-01-08 19:23:19 +08:00
#include <array> // Include array for std::array::at
2026-01-06 16:27:19 +08:00
namespace Basalt::Shared::Math {
using FloatPoint = float;
struct Vector3 {
FloatPoint x, y, z;
2026-01-08 19:23:19 +08:00
FloatPoint& operator[](size_t index);
const FloatPoint& operator[](size_t index) const;
2026-01-06 16:27:19 +08:00
};
2026-01-08 19:23:19 +08:00
2026-01-06 16:27:19 +08:00
struct Vector4 {
FloatPoint x, y, z, w;
2026-01-08 19:23:19 +08:00
FloatPoint& operator[](size_t index);
const FloatPoint& operator[](size_t index) const;
2026-01-06 16:27:19 +08:00
};
2026-01-08 19:23:19 +08:00
2026-01-06 16:27:19 +08:00
struct Matrix4x4 {
2026-01-08 19:23:19 +08:00
private:
std::array<Vector4, 4> data; // Use std::array instead of raw array for .at() method
2026-01-06 16:27:19 +08:00
2026-01-08 19:23:19 +08:00
public:
Vector4& operator[](size_t index);
const Vector4& operator[](size_t index) const;
};
2026-01-06 16:27:19 +08:00
#define NOT_IMPLEMENTED throw std::logic_error("not implemented function");
template<typename TNum, typename TVec>
struct Vector3Traits {};
template<typename TNum, typename TMat>
struct Matrix4x4Traits {};
#undef NOT_IMPLEMENTED
2026-01-08 19:23:19 +08:00
} // namespace Basalt::Shared::Math