mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 02:19:05 +08:00
Fix: Give more space for a rounding error to a supports spots generator test.
There was a test that relied on randomness and also checked the result with very hight precision. That led to a failed test once upon a time. Now the checking is more benevolent (it should be, as the code is not expected to be precise) and also the randomness is removed.
This commit is contained in:
parent
7462b91123
commit
b45e9d2830
@ -71,11 +71,8 @@ TEST_CASE("Moments calculation for rotated axis.", "[SupportSpotsGenerator]") {
|
||||
|
||||
Integrals integrals{{polygon}};
|
||||
|
||||
std::mt19937 generator{std::random_device{}()};
|
||||
std::uniform_real_distribution<float> angle_distribution{0.f, float(2*M_PI)};
|
||||
|
||||
// Meassured counterclockwise from (1, 0)
|
||||
const float angle = angle_distribution(generator);
|
||||
const float angle = 1.432f;
|
||||
Vec2f axis{std::cos(angle), std::sin(angle)};
|
||||
|
||||
float moment_calculated_then_rotated = compute_second_moment(
|
||||
@ -93,7 +90,8 @@ TEST_CASE("Moments calculation for rotated axis.", "[SupportSpotsGenerator]") {
|
||||
Vec2f{1, 0}
|
||||
);
|
||||
|
||||
CHECK(moment_calculated_then_rotated == Approx(moment_rotated_polygon));
|
||||
// Up to 0.1% accuracy
|
||||
CHECK_THAT(moment_calculated_then_rotated, Catch::Matchers::WithinRel(moment_rotated_polygon, 0.001f));
|
||||
}
|
||||
|
||||
struct ObjectPartFixture {
|
||||
|
Loading…
x
Reference in New Issue
Block a user