1
0

refactor shared

This commit is contained in:
2026-01-08 19:23:19 +08:00
parent 07cc58fb36
commit 64368b7837
23 changed files with 400 additions and 234 deletions

View File

@@ -1,5 +1,82 @@
#include "math.hpp"
#include <stdexcept> // Include for std::out_of_range
namespace Basalt::Shared::Math {
}
#pragma region Vector3
FloatPoint& Vector3::operator[](size_t index) {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range("Vector3 index out of range");
}
}
const FloatPoint& Vector3::operator[](size_t index) const {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range("Vector3 index out of range");
}
}
#pragma endregion
#pragma region Vector4
FloatPoint& Vector4::operator[](size_t index) {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
default:
throw std::out_of_range("Vector4 index out of range");
}
}
const FloatPoint& Vector4::operator[](size_t index) const {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
default:
throw std::out_of_range("Vector4 index out of range");
}
}
#pragma endregion
#pragma region Matrix4x4
Vector4& Matrix4x4::operator[](size_t index) {
return data.at(index);
}
const Vector4& Matrix4x4::operator[](size_t index) const {
return data.at(index);
}
#pragma endregion
} // namespace Basalt::Shared::Math