Skip to content
Snippets Groups Projects

Tests for ray projection and uniforms on circles and disks

Merged Aaron Grabowy requested to merge agrabowy into develop
2 files
+ 83
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 20
0
@@ -57,4 +57,24 @@ TG_FUZZ_TEST(TypedGeometry, Project)
auto dist1 = tg::distance_sqr(p, pn);
CHECK(dist1 == doctest::Approx(0.0f));
}
{
// ray
auto pos = uniform(rng, range3);
auto dir = tg::vec3();
while (length_sqr(dir) == 0)
dir = tg::vec3(uniform(rng, range3));
auto dirN = normalize(dir);
auto line = tg::line3(pos, dirN);
auto ray = tg::ray3(pos, dirN);
auto p = uniform(rng, range3);
auto projLine = tg::project(p, line);
auto projRay = tg::project(p, ray);
// The projection onto the ray is the same as onto the line if in positive direction, otherwise at the ray origin
auto diff = tg::distance_sqr(projRay,dot(p - pos, dir) > 0 ? projLine : pos);
CHECK(diff == doctest::Approx(0.0f));
}
}
Loading