mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
added more unit tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace omath::collision
|
||||
public:
|
||||
LineTracer() = delete;
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
static bool CanTraceLine(const Ray& ray, const Triangle3d& triangle);
|
||||
|
||||
|
||||
@@ -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},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
namespace omath::pathfinding
|
||||
{
|
||||
|
||||
enum Error
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class NavigationMesh final
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user