diff --git a/extern/typed-geometry b/extern/typed-geometry index 1a1a37b244af85f4fc28bdbb964b1065f3189d86..866b0b6f0eaf354fa17894ab91dac059e31aa394 160000 --- a/extern/typed-geometry +++ b/extern/typed-geometry @@ -1 +1 @@ -Subproject commit 1a1a37b244af85f4fc28bdbb964b1065f3189d86 +Subproject commit 866b0b6f0eaf354fa17894ab91dac059e31aa394 diff --git a/tests/feature/intersections/ray-intersect.cc b/tests/feature/intersections/ray-intersect.cc index bc352d86f00157d33a0d9707f7d567f61ce4f411..9cab42e5a5d9e519c45c5c0994405634d2e8a51a 100644 --- a/tests/feature/intersections/ray-intersect.cc +++ b/tests/feature/intersections/ray-intersect.cc @@ -2,15 +2,15 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) { - const auto tolerance = 0.002f; - const auto test_obj = [tolerance](const auto& ray, const auto& obj) { - const auto ts = tg::intersection_parameter(ray, obj); - for (const auto& t : ts) + auto const tolerance = 0.002f; + auto const test_obj = [tolerance](auto const& ray, auto const& obj) { + auto const ts = tg::intersection_parameter(ray, obj); + for (auto const& t : ts) { - const auto ip = ray[t]; + auto const ip = ray[t]; CHECK(contains(obj, ip, tolerance * tg::sqrt(t))); } - const auto t = tg::closest_intersection_parameter(ray, obj); + auto const t = tg::closest_intersection_parameter(ray, obj); if (t.has_value()) { CHECK(t.value() == ts.first()); @@ -20,7 +20,7 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) else CHECK(!intersects(ray, obj)); - const auto tsLine = tg::intersection_parameter(inf_of(ray), obj); + auto const tsLine = tg::intersection_parameter(inf_of(ray), obj); auto iRay = 0; for (auto iLine = 0; iLine < tsLine.size(); ++iLine) if (tsLine[iLine] >= 0) @@ -28,27 +28,27 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) CHECK(iRay == ts.size()); }; - const auto test_solid_obj = [tolerance, &rng](const auto& ray, const auto& obj) { - const auto ts = tg::intersection_parameter(ray, obj); + auto const test_solid_obj = [tolerance, &rng](auto const& ray, auto const& obj) { + auto const ts = tg::intersection_parameter(ray, obj); if (ts.has_value()) { - const auto interval = ts.value(); - const auto ip1 = ray[interval.start]; - const auto ip2 = ray[uniform(rng, interval.start, interval.end)]; - const auto ip3 = ray[interval.end]; + auto const interval = ts.value(); + auto const ip1 = ray[interval.start]; + auto const ip2 = ray[uniform(rng, interval.start, interval.end)]; + auto const ip3 = ray[interval.end]; CHECK(contains(obj, ip1, tolerance)); CHECK(contains(obj, ip2, tolerance)); CHECK(contains(obj, ip3, tolerance * tg::sqrt(interval.end))); - const auto t = tg::closest_intersection_parameter(ray, obj); + auto const t = tg::closest_intersection_parameter(ray, obj); CHECK(t.has_value()); CHECK(t.value() == ts.value().start); CHECK(closest_intersection(ray, obj) == ip1); CHECK(intersects(ray, obj)); - const auto tsLine = tg::intersection_parameter(inf_of(ray), obj); + auto const tsLine = tg::intersection_parameter(inf_of(ray), obj); CHECK(tsLine.has_value()); - const auto interLine = tsLine.value(); + auto const interLine = tsLine.value(); CHECK(interLine.end == interval.end); if (interLine.start < 0) CHECK(interval.start == 0); @@ -59,13 +59,13 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) CHECK(!intersects(ray, obj)); }; - const auto test_obj_and_boundary = [&](const auto& ray, const auto& obj) { - const auto bounds = boundary_of(obj); + auto const test_obj_and_boundary = [&](auto const& ray, auto const& obj) { + auto const bounds = boundary_of(obj); test_solid_obj(ray, obj); test_obj(ray, bounds); - const auto iObj = tg::closest_intersection_parameter(ray, obj); - const auto iBounds = tg::closest_intersection_parameter(ray, bounds); + auto const iObj = tg::closest_intersection_parameter(ray, obj); + auto const iBounds = tg::closest_intersection_parameter(ray, bounds); if (iBounds.has_value()) { CHECK(iObj.has_value()); @@ -74,16 +74,16 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) } }; - const auto test_obj_and_boundary_no_caps = [&](const auto& ray, const auto& obj) { - const auto bounds = boundary_of(obj); - const auto boundsNoCaps = boundary_no_caps_of(obj); + auto const test_obj_and_boundary_no_caps = [&](auto const& ray, auto const& obj) { + auto const bounds = boundary_of(obj); + auto const boundsNoCaps = boundary_no_caps_of(obj); test_solid_obj(ray, obj); test_obj(ray, bounds); test_obj(ray, boundsNoCaps); - const auto iObj = tg::closest_intersection_parameter(ray, obj); - const auto iBounds = tg::closest_intersection_parameter(ray, bounds); - const auto iBoundsNoCaps = tg::closest_intersection_parameter(ray, boundsNoCaps); + auto const iObj = tg::closest_intersection_parameter(ray, obj); + auto const iBounds = tg::closest_intersection_parameter(ray, bounds); + auto const iBoundsNoCaps = tg::closest_intersection_parameter(ray, boundsNoCaps); if (iBoundsNoCaps.has_value()) { CHECK(iBounds.has_value()); @@ -98,49 +98,49 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) } }; - const auto r = uniform(rng, 0.0f, 10.0f); - const auto h = uniform(rng, 0.0f, 10.0f); - const auto a = uniform(rng, 5_deg, 180_deg); // sensible range for a convex inf_cone - const auto n1 = tg::uniform<tg::dir1>(rng); - const auto n2 = tg::uniform<tg::dir2>(rng); - const auto n3 = tg::uniform<tg::dir3>(rng); - const auto n4 = tg::uniform<tg::dir4>(rng); + auto const r = uniform(rng, 0.0f, 10.0f); + auto const h = uniform(rng, 0.0f, 10.0f); + auto const a = uniform(rng, 5_deg, 180_deg); // sensible range for a convex inf_cone + auto const n1 = tg::uniform<tg::dir1>(rng); + auto const n2 = tg::uniform<tg::dir2>(rng); + auto const n3 = tg::uniform<tg::dir3>(rng); + auto const n4 = tg::uniform<tg::dir4>(rng); - const auto range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); - const auto range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); - const auto range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); - const auto range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); + auto const range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); + auto const range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); + auto const range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); + auto const range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); - const auto pos10 = uniform(rng, range1); - const auto pos11 = uniform(rng, range1); + auto const pos10 = uniform(rng, range1); + auto const pos11 = uniform(rng, range1); - const auto pos20 = uniform(rng, range2); - const auto pos21 = uniform(rng, range2); - const auto pos22 = uniform(rng, range2); + auto const pos20 = uniform(rng, range2); + auto const pos21 = uniform(rng, range2); + auto const pos22 = uniform(rng, range2); - const auto pos30 = uniform(rng, range3); - const auto pos31 = uniform(rng, range3); - const auto pos32 = uniform(rng, range3); + auto const pos30 = uniform(rng, range3); + auto const pos31 = uniform(rng, range3); + auto const pos32 = uniform(rng, range3); - const auto pos40 = uniform(rng, range4); - const auto pos41 = uniform(rng, range4); + auto const pos40 = uniform(rng, range4); + auto const pos41 = uniform(rng, range4); - const auto axis0 = tg::segment3(pos30, pos31); - const auto disk0 = tg::sphere2in3(pos30, r, n3); + auto const axis0 = tg::segment3(pos30, pos31); + auto const disk0 = tg::sphere2in3(pos30, r, n3); - const auto d1 = tg::uniform<tg::dir1>(rng); + auto const d1 = tg::uniform<tg::dir1>(rng); auto m1 = tg::mat1(); m1[0] = d1 * uniform(rng, 1.0f, 3.0f); - const auto d20 = tg::uniform<tg::dir2>(rng); - const auto d21 = perpendicular(d20); + auto const d20 = tg::uniform<tg::dir2>(rng); + auto const d21 = perpendicular(d20); auto m2 = tg::mat2(); m2[0] = d20 * uniform(rng, 1.0f, 3.0f); m2[1] = d21 * uniform(rng, 1.0f, 3.0f); - const auto d30 = tg::uniform<tg::dir3>(rng); - const auto d31 = any_normal(d30); - const auto d32 = normalize(cross(d30, d31)); + auto const d30 = tg::uniform<tg::dir3>(rng); + auto const d31 = any_normal(d30); + auto const d32 = normalize(cross(d30, d31)); auto m3 = tg::mat3(); m3[0] = d30 * uniform(rng, 1.0f, 3.0f); m3[1] = d31 * uniform(rng, 1.0f, 3.0f); @@ -151,10 +151,10 @@ TG_FUZZ_TEST(TypedGeometry, Intersections) m23[1] = d31 * uniform(rng, 1.0f, 3.0f); - const auto ray1 = tg::ray1(uniform(rng, range1), tg::uniform<tg::dir1>(rng)); - const auto ray2 = tg::ray2(uniform(rng, range2), tg::uniform<tg::dir2>(rng)); - const auto ray3 = tg::ray3(uniform(rng, range3), tg::uniform<tg::dir3>(rng)); - const auto ray4 = tg::ray4(uniform(rng, range4), tg::uniform<tg::dir4>(rng)); + auto const ray1 = tg::ray1(uniform(rng, range1), tg::uniform<tg::dir1>(rng)); + auto const ray2 = tg::ray2(uniform(rng, range2), tg::uniform<tg::dir2>(rng)); + auto const ray3 = tg::ray3(uniform(rng, range3), tg::uniform<tg::dir3>(rng)); + auto const ray4 = tg::ray4(uniform(rng, range4), tg::uniform<tg::dir4>(rng)); // aabb test_obj_and_boundary(ray1, aabb_of(pos10, pos11)); diff --git a/tests/feature/objects/aabb.cc b/tests/feature/objects/aabb.cc index 68362862060697c083e5aa561bf6748363751c2b..5836bd6c97da079b804a55ade7071449e13d20a5 100644 --- a/tests/feature/objects/aabb.cc +++ b/tests/feature/objects/aabb.cc @@ -24,40 +24,40 @@ TG_FUZZ_TEST(TypedGeometry, AABB) TG_FUZZ_TEST(TypedGeometry, ObjectAABB) {; - const auto test_obj = [&](auto obj) { + auto const test_obj = [&](auto const& obj) { auto bb = aabb_of(obj); auto p = uniform(rng, obj); CHECK(contains(bb, p)); }; - const auto r = uniform(rng, 0.0f, 10.0f); - const auto h = uniform(rng, 0.0f, 10.0f); - const auto n1 = tg::dir(uniform(rng, tg::sphere_boundary<1, float>::unit)); - const auto n2 = tg::dir(uniform(rng, tg::sphere_boundary<2, float>::unit)); - const auto n3 = tg::dir(uniform(rng, tg::sphere_boundary<3, float>::unit)); + auto const r = uniform(rng, 0.0f, 10.0f); + auto const h = uniform(rng, 0.0f, 10.0f); + auto const n1 = tg::dir(uniform(rng, tg::sphere_boundary<1, float>::unit)); + auto const n2 = tg::dir(uniform(rng, tg::sphere_boundary<2, float>::unit)); + auto const n3 = tg::dir(uniform(rng, tg::sphere_boundary<3, float>::unit)); - const auto range1 = tg::aabb1(-10,10); - const auto range2 = tg::aabb2(-10,10); - const auto range3 = tg::aabb3(-10,10); - const auto range4 = tg::aabb4(-10,10); + auto const range1 = tg::aabb1(-10,10); + auto const range2 = tg::aabb2(-10,10); + auto const range3 = tg::aabb3(-10,10); + auto const range4 = tg::aabb4(-10,10); - const auto pos10 = uniform(rng, range1); - const auto pos11 = uniform(rng, range1); + auto const pos10 = uniform(rng, range1); + auto const pos11 = uniform(rng, range1); - const auto pos20 = uniform(rng, range2); - const auto pos21 = uniform(rng, range2); - const auto pos22 = uniform(rng, range2); + auto const pos20 = uniform(rng, range2); + auto const pos21 = uniform(rng, range2); + auto const pos22 = uniform(rng, range2); - const auto pos30 = uniform(rng, range3); - const auto pos31 = uniform(rng, range3); - const auto pos32 = uniform(rng, range3); + auto const pos30 = uniform(rng, range3); + auto const pos31 = uniform(rng, range3); + auto const pos32 = uniform(rng, range3); - const auto pos40 = uniform(rng, range4); - const auto pos41 = uniform(rng, range4); - const auto pos42 = uniform(rng, range4); + auto const pos40 = uniform(rng, range4); + auto const pos41 = uniform(rng, range4); + auto const pos42 = uniform(rng, range4); - const auto axis0 = tg::segment3(pos30, pos31); + auto const axis0 = tg::segment3(pos30, pos31); auto d1 = tg::uniform<tg::dir1>(rng); auto m1 = tg::mat1(); diff --git a/tests/feature/objects/any_point.cc b/tests/feature/objects/any_point.cc index 00109c30561067379184db94a99818899338db04..ab9c7e387ff6650f27509d5e2b12ad5a88e06593 100644 --- a/tests/feature/objects/any_point.cc +++ b/tests/feature/objects/any_point.cc @@ -2,66 +2,66 @@ TG_FUZZ_TEST(TypedGeometry, AnyPoint) { - const auto tolerance = 0.001f; - const auto test_obj = [tolerance](const auto& o) { + auto const tolerance = 0.001f; + auto const test_obj = [tolerance](auto const& o) { auto p = any_point(o); CHECK(contains(o, p, tolerance)); }; - const auto test_obj_and_boundary = [&test_obj](const auto& o) { + auto const test_obj_and_boundary = [&test_obj](auto const& o) { test_obj(o); test_obj(boundary_of(o)); }; - const auto test_obj_and_boundary_no_caps = [&test_obj](const auto& o) { + auto const test_obj_and_boundary_no_caps = [&test_obj](auto const& o) { test_obj(o); test_obj(boundary_of(o)); test_obj(boundary_no_caps_of(o)); }; - const auto r = uniform(rng, 0.0f, 10.0f); - const auto h = uniform(rng, 0.0f, 10.0f); - const auto a = tg::uniform<tg::angle>(rng); - const auto n1 = tg::uniform<tg::dir1>(rng); - const auto n2 = tg::uniform<tg::dir2>(rng); - const auto n3 = tg::uniform<tg::dir3>(rng); - const auto n4 = tg::uniform<tg::dir4>(rng); + auto const r = uniform(rng, 0.0f, 10.0f); + auto const h = uniform(rng, 0.0f, 10.0f); + auto const a = tg::uniform<tg::angle>(rng); + auto const n1 = tg::uniform<tg::dir1>(rng); + auto const n2 = tg::uniform<tg::dir2>(rng); + auto const n3 = tg::uniform<tg::dir3>(rng); + auto const n4 = tg::uniform<tg::dir4>(rng); - const auto range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); - const auto range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); - const auto range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); - const auto range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); + auto const range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); + auto const range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); + auto const range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); + auto const range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); - const auto pos10 = uniform(rng, range1); - const auto pos11 = uniform(rng, range1); + auto const pos10 = uniform(rng, range1); + auto const pos11 = uniform(rng, range1); - const auto pos20 = uniform(rng, range2); - const auto pos21 = uniform(rng, range2); - const auto pos22 = uniform(rng, range2); + auto const pos20 = uniform(rng, range2); + auto const pos21 = uniform(rng, range2); + auto const pos22 = uniform(rng, range2); - const auto pos30 = uniform(rng, range3); - const auto pos31 = uniform(rng, range3); - const auto pos32 = uniform(rng, range3); + auto const pos30 = uniform(rng, range3); + auto const pos31 = uniform(rng, range3); + auto const pos32 = uniform(rng, range3); - const auto pos40 = uniform(rng, range4); - const auto pos41 = uniform(rng, range4); + auto const pos40 = uniform(rng, range4); + auto const pos41 = uniform(rng, range4); - const auto axis0 = tg::segment3(pos30, pos31); - const auto disk0 = tg::sphere2in3(pos30, r, n3); + auto const axis0 = tg::segment3(pos30, pos31); + auto const disk0 = tg::sphere2in3(pos30, r, n3); - const auto d1 = tg::uniform<tg::dir1>(rng); + auto const d1 = tg::uniform<tg::dir1>(rng); auto m1 = tg::mat1(); m1[0] = d1 * uniform(rng, 1.0f, 3.0f); - const auto d20 = tg::uniform<tg::dir2>(rng); - const auto d21 = perpendicular(d20); + auto const d20 = tg::uniform<tg::dir2>(rng); + auto const d21 = perpendicular(d20); auto m2 = tg::mat2(); m2[0] = d20 * uniform(rng, 1.0f, 3.0f); m2[1] = d21 * uniform(rng, 1.0f, 3.0f); - const auto d30 = tg::uniform<tg::dir3>(rng); - const auto d31 = any_normal(d30); - const auto d32 = normalize(cross(d30, d31)); + auto const d30 = tg::uniform<tg::dir3>(rng); + auto const d31 = any_normal(d30); + auto const d32 = normalize(cross(d30, d31)); auto m3 = tg::mat3(); m3[0] = d30 * uniform(rng, 1.0f, 3.0f); m3[1] = d31 * uniform(rng, 1.0f, 3.0f); diff --git a/tests/feature/objects/centroid.cc b/tests/feature/objects/centroid.cc index 03b7055def35706adb29ec4dc2920aa7cbe7b85f..09360733ab0b46a81b4beddd133ab8ed5db5b071 100644 --- a/tests/feature/objects/centroid.cc +++ b/tests/feature/objects/centroid.cc @@ -16,9 +16,9 @@ TG_FUZZ_TEST(TypedGeometry, Centroid) } { auto t = tg::triangle2(uniform(rng, range2), uniform(rng, range2), uniform(rng, range2)); - const auto center = centroid_of(t); + auto const center = centroid_of(t); CHECK(contains(t, center)); - const auto transl = uniform_vec(rng, range2); + auto const transl = uniform_vec(rng, range2); t.pos0.x += transl.x; t.pos0.y += transl.y; @@ -27,7 +27,7 @@ TG_FUZZ_TEST(TypedGeometry, Centroid) t.pos2.x += transl.x; t.pos2.y += transl.y; - const auto newCenter = center + transl; + auto const newCenter = center + transl; CHECK(contains(t, newCenter)); CHECK(centroid_of(t) == approx(newCenter)); @@ -56,84 +56,84 @@ TG_FUZZ_TEST(TypedGeometry, Centroid) { // tetrahedron - const auto pyTri = tg::pyramid<tg::triangle3>(tg::triangle3(uniform(rng, range3), uniform(rng, range3), uniform(rng, range3)), uniform(rng, 0.1f, 10.f)); + auto const pyTri = tg::pyramid<tg::triangle3>(tg::triangle3(uniform(rng, range3), uniform(rng, range3), uniform(rng, range3)), uniform(rng, 0.1f, 10.f)); auto center = apex_of(pyTri); - for (const auto& vertex : vertices_of(pyTri.base)) + for (auto const& vertex : vertices_of(pyTri.base)) center += vertex; center /= 4.f; - const auto centroid = centroid_of(pyTri); + auto const centroid = centroid_of(pyTri); CHECK(centroid == approx(center)); } } TG_FUZZ_TEST(TypedGeometry, CentroidByUniform) { - const auto tolerance = 0.25f; - const auto numSamples = 100000; + auto const tolerance = 0.25f; + auto const numSamples = 100000; - const auto test_obj = [&rng, numSamples, tolerance](const auto& o) { + auto const test_obj = [&rng, numSamples, tolerance](auto const& o) { auto center = uniform(rng, o); for (auto i = 1; i < numSamples; ++i) center += uniform(rng, o); center /= numSamples; - const auto centroid = centroid_of(o); - const auto relError = tg::distance_sqr(center, centroid) / tg::distance_sqr_to_origin(centroid); - const auto approxEqual = centroid == approx(center, tolerance) || relError <= tg::pow2(tolerance); + auto const centroid = centroid_of(o); + auto const relError = tg::distance_sqr(center, centroid) / tg::distance_sqr_to_origin(centroid); + auto const approxEqual = centroid == approx(center, tolerance) || relError <= tg::pow2(tolerance); CHECK(approxEqual); }; - const auto test_obj_and_boundary = [&test_obj](const auto& o) { + auto const test_obj_and_boundary = [&test_obj](auto const& o) { test_obj(o); test_obj(boundary_of(o)); }; - const auto test_obj_and_boundary_no_caps = [&test_obj](const auto& o) { + auto const test_obj_and_boundary_no_caps = [&test_obj](auto const& o) { test_obj(o); test_obj(boundary_of(o)); test_obj(boundary_no_caps_of(o)); }; - const auto r = uniform(rng, 0.0f, 10.0f); - const auto h = uniform(rng, 0.0f, 10.0f); - const auto n2 = tg::uniform<tg::dir2>(rng); - const auto n3 = tg::uniform<tg::dir3>(rng); + auto const r = uniform(rng, 0.0f, 10.0f); + auto const h = uniform(rng, 0.0f, 10.0f); + auto const n2 = tg::uniform<tg::dir2>(rng); + auto const n3 = tg::uniform<tg::dir3>(rng); - const auto range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); - const auto range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); - const auto range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); - const auto range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); + auto const range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); + auto const range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); + auto const range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); + auto const range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); - const auto pos10 = uniform(rng, range1); - const auto pos11 = uniform(rng, range1); + auto const pos10 = uniform(rng, range1); + auto const pos11 = uniform(rng, range1); - const auto pos20 = uniform(rng, range2); - const auto pos21 = uniform(rng, range2); - const auto pos22 = uniform(rng, range2); + auto const pos20 = uniform(rng, range2); + auto const pos21 = uniform(rng, range2); + auto const pos22 = uniform(rng, range2); - const auto pos30 = uniform(rng, range3); - const auto pos31 = uniform(rng, range3); - const auto pos32 = uniform(rng, range3); + auto const pos30 = uniform(rng, range3); + auto const pos31 = uniform(rng, range3); + auto const pos32 = uniform(rng, range3); - const auto pos40 = uniform(rng, range4); - const auto pos41 = uniform(rng, range4); - const auto pos42 = uniform(rng, range4); + auto const pos40 = uniform(rng, range4); + auto const pos41 = uniform(rng, range4); + auto const pos42 = uniform(rng, range4); - const auto axis0 = tg::segment3(pos30, pos31); - const auto disk0 = tg::sphere2in3(pos30, r, n3); + auto const axis0 = tg::segment3(pos30, pos31); + auto const disk0 = tg::sphere2in3(pos30, r, n3); - const auto d1 = tg::uniform<tg::dir1>(rng); + auto const d1 = tg::uniform<tg::dir1>(rng); auto m1 = tg::mat1(); m1[0] = d1 * uniform(rng, 1.0f, 3.0f); - const auto d20 = tg::uniform<tg::dir2>(rng); - const auto d21 = perpendicular(d20); + auto const d20 = tg::uniform<tg::dir2>(rng); + auto const d21 = perpendicular(d20); auto m2 = tg::mat2(); m2[0] = d20 * uniform(rng, 1.0f, 3.0f); m2[1] = d21 * uniform(rng, 1.0f, 3.0f); - const auto d30 = tg::uniform<tg::dir3>(rng); - const auto d31 = any_normal(d30); - const auto d32 = normalize(cross(d30, d31)); + auto const d30 = tg::uniform<tg::dir3>(rng); + auto const d31 = any_normal(d30); + auto const d32 = normalize(cross(d30, d31)); auto m3 = tg::mat3(); m3[0] = d30 * uniform(rng, 1.0f, 3.0f); m3[1] = d31 * uniform(rng, 1.0f, 3.0f); diff --git a/tests/feature/objects/project.cc b/tests/feature/objects/project.cc index 72bb5d256193eddd5105331c0a9f29b99979d443..c157b192eec81ba382b0cc6298a8a71ae35231bf 100644 --- a/tests/feature/objects/project.cc +++ b/tests/feature/objects/project.cc @@ -4,7 +4,7 @@ TG_FUZZ_TEST_MAX_ITS_MAX_CYCLES(TypedGeometry, Project, 25, 100'000'000'000) { - const auto test_obj = [&rng](const auto& p, const auto& o) { + auto const test_obj = [&rng](auto const& p, auto const& o) { auto proj = project(p, o); // Projected point lies in the object @@ -29,63 +29,63 @@ TG_FUZZ_TEST_MAX_ITS_MAX_CYCLES(TypedGeometry, Project, 25, 100'000'000'000) CHECK(dist == approx(0.0f)); }; - const auto test_obj_and_boundary = [&test_obj](const auto& p, const auto& o) { + auto const test_obj_and_boundary = [&test_obj](auto const& p, auto const& o) { test_obj(p, o); test_obj(p, boundary_of(o)); }; - const auto test_obj_and_boundary_no_caps = [&test_obj](const auto& p, const auto& o) { + auto const test_obj_and_boundary_no_caps = [&test_obj](auto const& p, auto const& o) { test_obj(p, o); test_obj(p, boundary_of(o)); test_obj(p, boundary_no_caps_of(o)); }; - const auto r = uniform(rng, 0.0f, 10.0f); - const auto h = uniform(rng, 0.0f, 10.0f); - const auto n2 = tg::uniform<tg::dir2>(rng); - const auto n3 = tg::uniform<tg::dir3>(rng); + auto const r = uniform(rng, 0.0f, 10.0f); + auto const h = uniform(rng, 0.0f, 10.0f); + auto const n2 = tg::uniform<tg::dir2>(rng); + auto const n3 = tg::uniform<tg::dir3>(rng); - const auto range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); - const auto range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); - const auto range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); - const auto range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); + auto const range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); + auto const range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); + auto const range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); + auto const range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); - const auto p1 = uniform(rng, range1); - const auto p2 = uniform(rng, range2); - const auto p3 = uniform(rng, range3); - const auto p4 = uniform(rng, range4); + auto const p1 = uniform(rng, range1); + auto const p2 = uniform(rng, range2); + auto const p3 = uniform(rng, range3); + auto const p4 = uniform(rng, range4); - const auto pos10 = uniform(rng, range1); - const auto pos11 = uniform(rng, range1); + auto const pos10 = uniform(rng, range1); + auto const pos11 = uniform(rng, range1); - const auto pos20 = uniform(rng, range2); - const auto pos21 = uniform(rng, range2); - const auto pos22 = uniform(rng, range2); + auto const pos20 = uniform(rng, range2); + auto const pos21 = uniform(rng, range2); + auto const pos22 = uniform(rng, range2); - const auto pos30 = uniform(rng, range3); - const auto pos31 = uniform(rng, range3); - const auto pos32 = uniform(rng, range3); + auto const pos30 = uniform(rng, range3); + auto const pos31 = uniform(rng, range3); + auto const pos32 = uniform(rng, range3); - const auto pos40 = uniform(rng, range4); - const auto pos41 = uniform(rng, range4); + auto const pos40 = uniform(rng, range4); + auto const pos41 = uniform(rng, range4); - const auto axis0 = tg::segment3(pos30, pos31); - const auto disk0 = tg::sphere2in3(pos30, r, n3); + auto const axis0 = tg::segment3(pos30, pos31); + auto const disk0 = tg::sphere2in3(pos30, r, n3); - const auto d1 = tg::uniform<tg::dir1>(rng); + auto const d1 = tg::uniform<tg::dir1>(rng); auto m1 = tg::mat1(); m1[0] = d1 * uniform(rng, 1.0f, 3.0f); - const auto d20 = tg::uniform<tg::dir2>(rng); - const auto d21 = perpendicular(d20); + auto const d20 = tg::uniform<tg::dir2>(rng); + auto const d21 = perpendicular(d20); auto m2 = tg::mat2(); m2[0] = d20 * uniform(rng, 1.0f, 3.0f); m2[1] = d21 * uniform(rng, 1.0f, 3.0f); - const auto d30 = tg::uniform<tg::dir3>(rng); - const auto d31 = any_normal(d30); - const auto d32 = normalize(cross(d30, d31)); + auto const d30 = tg::uniform<tg::dir3>(rng); + auto const d31 = any_normal(d30); + auto const d32 = normalize(cross(d30, d31)); auto m3 = tg::mat3(); m3[0] = d30 * uniform(rng, 1.0f, 3.0f); m3[1] = d31 * uniform(rng, 1.0f, 3.0f); diff --git a/tests/feature/random/uniform.cc b/tests/feature/random/uniform.cc index fbba9ec5399229f1f0941f0abe0d48c6df460185..7bcf2431578c9399d570e7515c366a62b3a27867 100644 --- a/tests/feature/random/uniform.cc +++ b/tests/feature/random/uniform.cc @@ -39,10 +39,10 @@ TG_FUZZ_TEST(TypedGeometry, Uniform) TG_FUZZ_TEST_MAX_ITS(TypedGeometry, UniformGeneralProperties, 100) { - const auto tolerance = 0.01f; - const tg::u64 sampleSize = 32; + auto const tolerance = 0.01f; + tg::u64 const sampleSize = 32; - auto const test_obj = [&rng, tolerance](auto samples, auto o) { + auto const test_obj = [&rng, tolerance](auto samples, auto const& o) { for (tg::u64 i = 0; i < samples.size(); ++i) { auto p = uniform(rng, o); @@ -54,12 +54,12 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, UniformGeneralProperties, 100) } }; - auto const test_obj_and_boundary = [&test_obj](auto p, auto o) { + auto const test_obj_and_boundary = [&test_obj](auto const& p, auto const& o) { test_obj(p, o); test_obj(p, boundary_of(o)); }; - auto const test_obj_and_boundary_no_caps = [&test_obj](auto p, auto o) { + auto const test_obj_and_boundary_no_caps = [&test_obj](auto const& p, auto const& o) { test_obj(p, o); test_obj(p, boundary_of(o)); test_obj(p, boundary_no_caps_of(o)); @@ -71,46 +71,46 @@ TG_FUZZ_TEST_MAX_ITS(TypedGeometry, UniformGeneralProperties, 100) auto samples3 = tg::array<tg::pos3, sampleSize>(); auto samples4 = tg::array<tg::pos4, sampleSize>(); - const auto r = uniform(rng, 0.0f, 10.0f); - const auto h = uniform(rng, 0.0f, 10.0f); - const auto n2 = tg::uniform<tg::dir2>(rng); - const auto n3 = tg::uniform<tg::dir3>(rng); + auto const r = uniform(rng, 0.0f, 10.0f); + auto const h = uniform(rng, 0.0f, 10.0f); + auto const n2 = tg::uniform<tg::dir2>(rng); + auto const n3 = tg::uniform<tg::dir3>(rng); - const auto range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); - const auto range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); - const auto range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); - const auto range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); + auto const range1 = tg::aabb1(tg::pos1(-10), tg::pos1(10)); + auto const range2 = tg::aabb2(tg::pos2(-10), tg::pos2(10)); + auto const range3 = tg::aabb3(tg::pos3(-10), tg::pos3(10)); + auto const range4 = tg::aabb4(tg::pos4(-10), tg::pos4(10)); - const auto pos10 = uniform(rng, range1); - const auto pos11 = uniform(rng, range1); + auto const pos10 = uniform(rng, range1); + auto const pos11 = uniform(rng, range1); - const auto pos20 = uniform(rng, range2); - const auto pos21 = uniform(rng, range2); - const auto pos22 = uniform(rng, range2); + auto const pos20 = uniform(rng, range2); + auto const pos21 = uniform(rng, range2); + auto const pos22 = uniform(rng, range2); - const auto pos30 = uniform(rng, range3); - const auto pos31 = uniform(rng, range3); - const auto pos32 = uniform(rng, range3); + auto const pos30 = uniform(rng, range3); + auto const pos31 = uniform(rng, range3); + auto const pos32 = uniform(rng, range3); - const auto pos40 = uniform(rng, range4); - const auto pos41 = uniform(rng, range4); + auto const pos40 = uniform(rng, range4); + auto const pos41 = uniform(rng, range4); - const auto axis0 = tg::segment3(pos30, pos31); - const auto disk0 = tg::sphere2in3(pos30, r, n3); + auto const axis0 = tg::segment3(pos30, pos31); + auto const disk0 = tg::sphere2in3(pos30, r, n3); - const auto d1 = tg::uniform<tg::dir1>(rng); + auto const d1 = tg::uniform<tg::dir1>(rng); auto m1 = tg::mat1(); m1[0] = d1 * uniform(rng, 1.0f, 3.0f); - const auto d20 = tg::uniform<tg::dir2>(rng); - const auto d21 = perpendicular(d20); + auto const d20 = tg::uniform<tg::dir2>(rng); + auto const d21 = perpendicular(d20); auto m2 = tg::mat2(); m2[0] = d20 * uniform(rng, 1.0f, 3.0f); m2[1] = d21 * uniform(rng, 1.0f, 3.0f); - const auto d30 = tg::uniform<tg::dir3>(rng); - const auto d31 = any_normal(d30); - const auto d32 = normalize(cross(d30, d31)); + auto const d30 = tg::uniform<tg::dir3>(rng); + auto const d31 = any_normal(d30); + auto const d32 = normalize(cross(d30, d31)); auto m3 = tg::mat3(); m3[0] = d30 * uniform(rng, 1.0f, 3.0f); m3[1] = d31 * uniform(rng, 1.0f, 3.0f);