Commit 947c846e authored by Julian Schakib's avatar Julian Schakib
Browse files

fix inf_cone plane intersection tests

parent 7fde57d4
Pipeline #13750 failed with stage
in 6 minutes and 33 seconds
typed-geometry @ 8b84eb75
Subproject commit e1b6ba80c076f446f7943b83ae3992ce7751fb24
Subproject commit 8b84eb7530b201630c291c88f279ff9b3321d8d9
......@@ -148,22 +148,53 @@ TG_FUZZ_TEST(Plane, Intersect)
auto const center = uniform(rng, box);
auto const d = tg::uniform<tg::dir3>(rng);
auto const c = tg::inf_cone<3, tg::f32>(center, d, tg::degree(uniform(rng, 1.0f, 80.0f)));
auto opening_angle = tg::degree(uniform(rng, 1.0f, 89.0f));
auto c = tg::inf_cone<3, tg::f32>(center, d, opening_angle);
// checking whether flipping the plane's normal makes a difference (should not)
{
auto p = tg::plane3(d, center + d);
CHECK(intersects(c, p));
auto c = tg::inf_cone<3, tg::f32>(center, -d, opening_angle);
CHECK(!intersects(c, p));
}
p = tg::plane3(d, center - d);
{
auto p = tg::plane3(-d, center + d);
CHECK(intersects(c, p));
auto c = tg::inf_cone<3, tg::f32>(center, -d, opening_angle);
CHECK(!intersects(c, p));
}
{
auto p = tg::plane3(d, center - d);
CHECK(!intersects(c, p));
auto c = tg::inf_cone<3, tg::f32>(center, -d, opening_angle);
CHECK(intersects(c, p));
}
p.normal = any_normal(d);
{
auto p = tg::plane3(-d, center - d);
CHECK(!intersects(c, p));
auto c = tg::inf_cone<3, tg::f32>(center, -d, opening_angle);
CHECK(intersects(c, p));
}
auto rotation_mat = tg::rotation_around(any_normal(d), c.opening_angle);
auto new_normal = normalize(rotation_mat * d);
new_normal = any_normal(new_normal);
p = tg::plane3(new_normal, center + d * 100);
// rotate plane normal so that it intersects/does not intersect the cone
{
auto rotation_mat = tg::rotation_around(any_normal(d), tg::degree(89) - c.opening_angle);
auto new_normal = normalize(rotation_mat * (-d));
auto p = tg::plane3(new_normal, center - d);
// TODO should not intersect! is moved away from center and normal is oriented so that the plane runs parallel to the cone (?)
CHECK(!intersects(c, p));
}
{
auto rotation_mat = tg::rotation_around(any_normal(d), tg::degree(91) - c.opening_angle);
auto new_normal = normalize(rotation_mat * (-d));
auto p = tg::plane3(new_normal, center - d);
CHECK(intersects(c, p));
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment