Commit 2fed0b35 authored by Julian Schakib's avatar Julian Schakib
Browse files

contains and intersection tests

parent 4fb7e84e
Pipeline #13549 failed with stage
in 2 minutes and 16 seconds
typed-geometry @ b2ed42c0
Subproject commit f9d4c00561c281f740d3633d106b319a5555a46a
Subproject commit b2ed42c02755624e1e53062efaa2905c14a489da
......@@ -40,11 +40,26 @@ TG_FUZZ_TEST(Plane, Intersect)
CHECK(tg::intersects(p, to));
// move plane
auto const n = tg::uniform<tg::dir3>(rng);
auto const n = tg::uniform<tg::dir3>(rng);
auto const pm = tg::plane(n, to.center + n * to.radius);
auto const eps = to.radius / 10000;
CHECK(intersects(pm, to, eps));
CHECK(!intersects(pm, to, -eps));
}
// plane3 - inf_cone3_boundary
{
auto const box = tg::aabb3(tg::pos3(-10.0f), tg::pos3(10.0f));
// inf_boundary
auto c = tg::inf_cylinder_boundary<3, tg::f32>(tg::line3(tg::uniform(rng, box), tg::uniform<tg::dir3>(rng)), tg::uniform(rng, 0.1f, 10.0f));
auto const p = tg::plane3(tg::dir3::pos_y, tg::pos3::zero);
auto ellipse = tg::intersection(p, c);
// TODO what to check?
(void)ellipse;
}
}
......@@ -123,3 +123,17 @@ TG_FUZZ_TEST(TypedGeometry, ContainsCylinder)
CHECK(!contains(cyl, c + n * h / 2 * above));
CHECK(!contains(cyl, c - n * h / 2 * above));
}
TG_FUZZ_TEST(TypedGeometry, ContainsInfCylinderBoundary)
{
auto const box = tg::aabb3(tg::pos3(-10.0f), tg::pos3(10.0f));
// inf_boundary
auto const c = tg::inf_cylinder_boundary<3, tg::f32>(tg::line3(tg::uniform(rng, box), tg::uniform<tg::dir3>(rng)), tg::uniform(rng, 0.1f, 10.0f));
CHECK(!tg::contains(c, c.axis.pos));
CHECK(!tg::contains(c, c.axis.pos + any_normal(c.axis.dir) * c.radius * 0.9f));
CHECK(tg::contains(c, c.axis.pos + any_normal(c.axis.dir) * c.radius, c.radius / 100000));
CHECK(!tg::contains(c, c.axis.pos + any_normal(c.axis.dir) * c.radius * 1.1f));
}
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