mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
improved tests
This commit is contained in:
@@ -111,7 +111,6 @@ TEST(unit_test_iw_engine, loook_at_random_all_axis)
|
|||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::iw_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::iw_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
|
||||||
std::size_t failed_points = 0;
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
@@ -129,7 +128,7 @@ TEST(unit_test_iw_engine, loook_at_random_all_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (std::abs(projected_pos->x-0.f) >= 0.01f || std::abs(projected_pos->y-0.f) >= 0.01f)
|
if (std::abs(projected_pos->x - 0.f) >= 0.001f || std::abs(projected_pos->y - 0.f) >= 0.001f)
|
||||||
failed_points++;
|
failed_points++;
|
||||||
}
|
}
|
||||||
EXPECT_LE(failed_points, 100);
|
EXPECT_LE(failed_points, 100);
|
||||||
@@ -138,13 +137,12 @@ TEST(unit_test_iw_engine, loook_at_random_all_axis)
|
|||||||
TEST(unit_test_iw_engine, loook_at_random_x_axis)
|
TEST(unit_test_iw_engine, loook_at_random_x_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::iw_engine::Camera({dist(gen), dist(gen), dist(gen)}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::iw_engine::Camera({dist(gen), dist(gen), dist(gen)}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
||||||
@@ -161,21 +159,21 @@ TEST(unit_test_iw_engine, loook_at_random_x_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_iw_engine, loook_at_random_y_axis)
|
TEST(unit_test_iw_engine, loook_at_random_y_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::iw_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::iw_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
||||||
@@ -191,22 +189,22 @@ TEST(unit_test_iw_engine, loook_at_random_y_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_iw_engine, loook_at_random_z_axis)
|
TEST(unit_test_iw_engine, loook_at_random_z_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::iw_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::iw_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
||||||
if (cam.get_origin().distance_to(position_to_look) < 10)
|
if (cam.get_origin().distance_to(position_to_look) < 10)
|
||||||
@@ -221,7 +219,8 @@ TEST(unit_test_iw_engine, loook_at_random_z_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.025f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.025f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ TEST(unit_test_opengl_engine, loook_at_random_all_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
if (std::abs(projected_pos->x - 0.f) >= 0.0001f || std::abs(projected_pos->y - 0.f) >= 0.0001f)
|
||||||
failed_points++;
|
failed_points++;
|
||||||
}
|
}
|
||||||
EXPECT_LE(failed_points, 100);
|
EXPECT_LE(failed_points, 100);
|
||||||
@@ -134,11 +134,11 @@ TEST(unit_test_opengl_engine, loook_at_random_all_axis)
|
|||||||
TEST(unit_test_opengl_engine, loook_at_random_x_axis)
|
TEST(unit_test_opengl_engine, loook_at_random_x_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
||||||
@@ -155,19 +155,20 @@ TEST(unit_test_opengl_engine, loook_at_random_x_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_opengl_engine, loook_at_random_y_axis)
|
TEST(unit_test_opengl_engine, loook_at_random_y_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
||||||
@@ -184,19 +185,20 @@ TEST(unit_test_opengl_engine, loook_at_random_y_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_opengl_engine, loook_at_random_z_axis)
|
TEST(unit_test_opengl_engine, loook_at_random_z_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::opengl_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
||||||
@@ -212,7 +214,8 @@ TEST(unit_test_opengl_engine, loook_at_random_z_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.025f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,6 @@ TEST(unit_test_source_engine, ProjectTargetMovedFromCamera)
|
|||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
const auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
const auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
|
|
||||||
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
|
for (float distance = 0.02f; distance < 1000.f; distance += 0.01f)
|
||||||
{
|
{
|
||||||
const auto projected = cam.world_to_screen({distance, 0, 0});
|
const auto projected = cam.world_to_screen({distance, 0, 0});
|
||||||
@@ -132,8 +131,6 @@ TEST(unit_test_source_engine, loook_at_random_all_axis)
|
|||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::size_t failed_points = 0;
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
@@ -151,7 +148,7 @@ TEST(unit_test_source_engine, loook_at_random_all_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (std::abs(projected_pos->x-0.f) >= 0.01f || std::abs(projected_pos->y-0.f) >= 0.01f)
|
if (std::abs(projected_pos->x - 0.f) >= 0.0001f || std::abs(projected_pos->y - 0.f) >= 0.0001f)
|
||||||
failed_points++;
|
failed_points++;
|
||||||
}
|
}
|
||||||
EXPECT_LE(failed_points, 100);
|
EXPECT_LE(failed_points, 100);
|
||||||
@@ -160,13 +157,12 @@ TEST(unit_test_source_engine, loook_at_random_all_axis)
|
|||||||
TEST(unit_test_source_engine, loook_at_random_x_axis)
|
TEST(unit_test_source_engine, loook_at_random_x_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
||||||
@@ -182,21 +178,21 @@ TEST(unit_test_source_engine, loook_at_random_x_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_source_engine, loook_at_random_y_axis)
|
TEST(unit_test_source_engine, loook_at_random_y_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
||||||
@@ -212,21 +208,21 @@ TEST(unit_test_source_engine, loook_at_random_y_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_source_engine, loook_at_random_z_axis)
|
TEST(unit_test_source_engine, loook_at_random_z_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::source_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
||||||
@@ -242,7 +238,8 @@ TEST(unit_test_source_engine, loook_at_random_z_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.025f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.025f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,6 @@ TEST(unit_test_unity_engine, ProjectTargetMovedFromCamera)
|
|||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
|
||||||
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 1000.f);
|
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
|
|
||||||
for (float distance = 0.02f; distance < 100.f; distance += 0.01f)
|
for (float distance = 0.02f; distance < 100.f; distance += 0.01f)
|
||||||
{
|
{
|
||||||
const auto projected = cam.world_to_screen({0, 0, distance});
|
const auto projected = cam.world_to_screen({0, 0, distance});
|
||||||
@@ -122,9 +121,8 @@ TEST(unit_test_unity_engine, loook_at_random_all_axis)
|
|||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::size_t failed_points = 0;
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{dist(gen), dist(gen), dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{dist(gen), dist(gen), dist(gen)};
|
||||||
@@ -141,7 +139,7 @@ TEST(unit_test_unity_engine, loook_at_random_all_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (std::abs(projected_pos->x-0.f) >= 0.01f || std::abs(projected_pos->y-0.f) >= 0.01f)
|
if (std::abs(projected_pos->x - 0.f) >= 0.0001f || std::abs(projected_pos->y - 0.f) >= 0.0001f)
|
||||||
failed_points++;
|
failed_points++;
|
||||||
}
|
}
|
||||||
EXPECT_LE(failed_points, 100);
|
EXPECT_LE(failed_points, 100);
|
||||||
@@ -150,13 +148,12 @@ TEST(unit_test_unity_engine, loook_at_random_all_axis)
|
|||||||
TEST(unit_test_unity_engine, loook_at_random_x_axis)
|
TEST(unit_test_unity_engine, loook_at_random_x_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
const auto position_to_look = omath::Vector3<float>{dist(gen), 0.f, 0.f};
|
||||||
@@ -172,21 +169,21 @@ TEST(unit_test_unity_engine, loook_at_random_x_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.001f || std::abs(projected_pos->y - 0.f) >= 0.001f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_unity_engine, loook_at_random_y_axis)
|
TEST(unit_test_unity_engine, loook_at_random_y_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
||||||
@@ -202,21 +199,21 @@ TEST(unit_test_unity_engine, loook_at_random_y_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_unity_engine, loook_at_random_z_axis)
|
TEST(unit_test_unity_engine, loook_at_random_z_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
||||||
@@ -232,7 +229,8 @@ TEST(unit_test_unity_engine, loook_at_random_z_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.025f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,6 @@ TEST(unit_test_unreal_engine, ProjectTargetMovedFromCamera)
|
|||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
|
||||||
const auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 1000.f);
|
const auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 1000.f);
|
||||||
|
|
||||||
|
|
||||||
for (float distance = 0.02f; distance < 100.f; distance += 0.01f)
|
for (float distance = 0.02f; distance < 100.f; distance += 0.01f)
|
||||||
{
|
{
|
||||||
const auto projected = cam.world_to_screen({distance, 0, 0});
|
const auto projected = cam.world_to_screen({distance, 0, 0});
|
||||||
@@ -114,7 +113,7 @@ TEST(unit_test_unreal_engine, loook_at_random_all_axis)
|
|||||||
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{dist(gen), dist(gen), dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{dist(gen), dist(gen), dist(gen)};
|
||||||
@@ -130,21 +129,20 @@ TEST(unit_test_unreal_engine, loook_at_random_all_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.01f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.0001f || std::abs(projected_pos->y - 0.f) >= 0.0001f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.01f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_unreal_engine, loook_at_random_x_axis)
|
TEST(unit_test_unreal_engine, loook_at_random_x_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::size_t failed_points = 0;
|
std::size_t failed_points = 0;
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
@@ -162,7 +160,7 @@ TEST(unit_test_unreal_engine, loook_at_random_x_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (std::abs(projected_pos->x-0.f) >= 0.01f || std::abs(projected_pos->y-0.f) >= 0.01f)
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
failed_points++;
|
failed_points++;
|
||||||
}
|
}
|
||||||
EXPECT_LE(failed_points, 100);
|
EXPECT_LE(failed_points, 100);
|
||||||
@@ -171,13 +169,12 @@ TEST(unit_test_unreal_engine, loook_at_random_x_axis)
|
|||||||
TEST(unit_test_unreal_engine, loook_at_random_y_axis)
|
TEST(unit_test_unreal_engine, loook_at_random_y_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
||||||
@@ -194,21 +191,21 @@ TEST(unit_test_unreal_engine, loook_at_random_y_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(unit_test_unreal_engine, loook_at_random_z_axis)
|
TEST(unit_test_unreal_engine, loook_at_random_z_axis)
|
||||||
{
|
{
|
||||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||||
std::uniform_real_distribution<float> dist(-500.f, 500.f);
|
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||||
|
|
||||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||||
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||||
|
|
||||||
|
std::size_t failed_points = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
||||||
@@ -225,7 +222,8 @@ TEST(unit_test_unreal_engine, loook_at_random_z_axis)
|
|||||||
if (!projected_pos)
|
if (!projected_pos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EXPECT_NEAR(projected_pos->x, 0.f, 0.00001f);
|
if (std::abs(projected_pos->x - 0.f) >= 0.01f || std::abs(projected_pos->y - 0.f) >= 0.01f)
|
||||||
EXPECT_NEAR(projected_pos->y, 0.f, 0.00001f);
|
failed_points++;
|
||||||
}
|
}
|
||||||
|
EXPECT_LE(failed_points, 100);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user