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

146 lines
3.6 KiB
C++
Raw Normal View History

2026-01-06 16:27:19 +08:00
#include "math.hpp"
2026-01-08 19:23:19 +08:00
#include <stdexcept> // Include for std::out_of_range
2026-01-06 16:27:19 +08:00
2026-01-09 16:40:30 +08:00
namespace basalt::shared::math {
#pragma region Triangle
Index& Triangle::operator[](size_t index) {
switch (index) {
case 0:
return i;
case 1:
return j;
case 2:
return k;
default:
throw std::out_of_range("Triangle index out of range");
}
}
const Index& Triangle::operator[](size_t index) const {
switch (index) {
case 0:
return i;
case 1:
return j;
case 2:
return k;
default:
throw std::out_of_range("Triangle index out of range");
}
}
#pragma endregion
2026-01-06 16:27:19 +08:00
2026-01-08 19:23:19 +08:00
#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
2026-01-09 16:40:30 +08:00
#pragma region Quaternion
2026-01-08 19:23:19 +08:00
2026-01-09 16:40:30 +08:00
FloatPoint& Quaternion::operator[](size_t index) {
2026-01-08 19:23:19 +08:00
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
default:
2026-01-09 16:40:30 +08:00
throw std::out_of_range("Quaternion index out of range");
2026-01-08 19:23:19 +08:00
}
}
2026-01-09 16:40:30 +08:00
const FloatPoint& Quaternion::operator[](size_t index) const {
2026-01-08 19:23:19 +08:00
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
default:
2026-01-09 16:40:30 +08:00
throw std::out_of_range("Quaternion index out of range");
2026-01-08 19:23:19 +08:00
}
}
#pragma endregion
2026-01-09 16:40:30 +08:00
//
//#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
2026-01-08 19:23:19 +08:00
2026-01-09 16:40:30 +08:00
} // namespace basalt::shared::math