Commit 12c214c8 authored by Julian Schakib's avatar Julian Schakib
Browse files

new tg and tests

parent 5ef5d0c5
Pipeline #13397 passed with stage
in 6 minutes and 57 seconds
typed-geometry @ 142498d6
Subproject commit a4f2b32b2b475075f1e16c61aed8f8357f267479
Subproject commit 142498d69cea6f734ebdeb05c05e6b788f0cb86c
......@@ -22,6 +22,10 @@ TG_FUZZ_TEST(TypedGeometry, InfConeContainsPos)
CHECK(contains(cone, p0 + z * tan(cone.opening_angle * 0.9f) + y));
CHECK(!contains(cone, p0 + z * tan(cone.opening_angle * 1.1f) + y));
auto anc = uniform(rng, 0.1f, 10.0f);
CHECK(contains(cone, p0 + z * tan(cone.opening_angle * 0.99f) * anc + y * anc));
CHECK(!contains(cone, p0 + z * tan(cone.opening_angle * 1.01f) * anc + y * anc));
}
TG_FUZZ_TEST(TypedGeometry, ContainsBox)
......
......@@ -2,6 +2,25 @@
#include <typed-geometry/tg-std.hh>
TG_FUZZ_TEST(TypedGeometry, IntersectionRay3InfCone3)
{
auto box3 = tg::aabb3(tg::pos3(-10.0f), tg::pos3(10.0f));
// random ray
auto r1 = tg::ray3(uniform(rng, box3), normalize(tg::vec3(uniform(rng, box3))));
auto mirrored = tg::ray3(r1.origin - r1.dir * 0.01f, -r1.dir);
auto cone = tg::inf_cone3(r1.origin, r1.dir, tg::radians(tg::pi_scalar<tg::f32> / 3));
CHECK(tg::intersects(r1, cone));
CHECK(!tg::intersects(mirrored, cone));
auto eps = -tg::radians(tg::epsilon<tg::f32> * 10);
auto boundaryDir = normalize(cone.opening_dir + tg::any_normal(cone.opening_dir) * tan(cone.opening_angle + eps));
auto borderRay = tg::ray3(cone.apex, boundaryDir);
CHECK(tg::intersects(borderRay, cone));
}
TG_FUZZ_TEST(TypedGeometry, IntersectionRay3Ray3)
{
auto box3 = tg::aabb3(tg::pos3(-10.0f), tg::pos3(10.0f));
......@@ -11,7 +30,7 @@ TG_FUZZ_TEST(TypedGeometry, IntersectionRay3Ray3)
// not-parallel new direction
auto newDir = r1.dir;
while(tg::abs(dot(newDir, r1.dir)) > 0.9f)
while (tg::abs(dot(newDir, r1.dir)) > 0.9f)
newDir = normalize(tg::vec3(uniform(rng, box3)));
{
......
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