mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-14 07:23:26 +00:00
Adds projection test for world-to-screen consistency
Adds a test to verify the consistency of world-to-screen and screen-to-world projections. This ensures that projecting a point from world to screen and back results in the same point, thereby validating the correctness of the camera projection transformations.
This commit is contained in:
@@ -16,6 +16,9 @@ TEST(UnitTestProjection, Projection)
|
|||||||
const auto projected = cam.world_to_screen({1000, 0, 50.f});
|
const auto projected = cam.world_to_screen({1000, 0, 50.f});
|
||||||
const auto result = cam.screen_to_world(projected.value());
|
const auto result = cam.screen_to_world(projected.value());
|
||||||
const auto result2 = cam.world_to_screen(result.value());
|
const auto result2 = cam.world_to_screen(result.value());
|
||||||
|
|
||||||
|
EXPECT_EQ(static_cast<omath::Vector2<float>>(projected.value()),
|
||||||
|
static_cast<omath::Vector2<float>>(result2.value()));
|
||||||
EXPECT_NEAR(projected->x, 960.f, 0.001f);
|
EXPECT_NEAR(projected->x, 960.f, 0.001f);
|
||||||
EXPECT_NEAR(projected->y, 504.f, 0.001f);
|
EXPECT_NEAR(projected->y, 504.f, 0.001f);
|
||||||
EXPECT_NEAR(projected->z, 1.f, 0.001f);
|
EXPECT_NEAR(projected->z, 1.f, 0.001f);
|
||||||
|
|||||||
Reference in New Issue
Block a user