added more unit tests

This commit is contained in:
2024-11-30 03:37:25 +03:00
parent 6a9a51b39c
commit a33ee638b9
7 changed files with 84 additions and 10 deletions

View File

@@ -7,12 +7,39 @@
namespace omath::angles
{
[[nodiscard]] constexpr float RadiansToDegrees(const float radiands)
template<class type>
requires std::is_floating_point_v<type>
[[nodiscard]] constexpr float RadiansToDegrees(const type& radians)
{
return radiands * (180.f / std::numbers::pi_v<float>);
return radians * (type(180) / std::numbers::pi_v<type>);
}
[[nodiscard]] constexpr float DegreesToRadians(const float degrees)
template<class type>
requires std::is_floating_point_v<type>
[[nodiscard]] constexpr float DegreesToRadians(const type& degrees)
{
return degrees * (std::numbers::pi_v<float> / 180.f);
return degrees * (std::numbers::pi_v<type> / type(180));
}
template<class type>
requires std::is_floating_point_v<type>
[[nodiscard]] type HorizontalFovToVertical(const type& horFov, const type& aspect)
{
const auto fovRad = DegreesToRadians(horFov);
const auto vertFov = type(2) * std::atan(std::tan(fovRad / type(2)) / aspect);
return RadiansToDegrees(vertFov);
}
template<class type>
requires std::is_floating_point_v<type>
[[nodiscard]] type VerticalFovToHorizontal(const type& vertFov, const type& aspect)
{
const auto fovRad = DegreesToRadians(vertFov);
const auto horFov = type(2) * std::atan(std::tan(fovRad / type(2)) * aspect);
return RadiansToDegrees(horFov);
}
}

View File

@@ -26,6 +26,7 @@ namespace omath::collision
public:
LineTracer() = delete;
[[nodiscard]]
static bool CanTraceLine(const Ray& ray, const Triangle3d& triangle);

View File

@@ -22,10 +22,10 @@ namespace omath::opengl
{
return
{
{right.x, up.x, -forward.x, 0},
{right.y, up.y, -forward.y, 0},
{right.z, up.z, -forward.z, 0},
{-cam_origin.x, -cam_origin.y, -cam_origin.z, 1},
{right.x, up.x, -forward.x, 0},
{right.y, up.y, -forward.y, 0},
{right.z, up.z, -forward.z, 0},
{-cam_origin.x, -cam_origin.y, -cam_origin.z, 1},
};
}

View File

@@ -12,6 +12,12 @@
namespace omath::pathfinding
{
enum Error
{
};
class NavigationMesh final
{
public: