Commit 10e29669 authored by Philip Trettner's avatar Philip Trettner
Browse files

change doctest::Approx to approx

parent 490fd596
......@@ -11,8 +11,8 @@ void test_fwd_vs_finite_diff(F&& f, T val, T eps = T(1e-4))
auto v0 = f(val);
auto v1 = f(val + eps);
auto g = (v1 - v0) / eps;
CHECK(v0 == doctest::Approx(fd_result.value));
CHECK(g == doctest::Approx(fd_result.derivative).epsilon(.01));
CHECK(v0 == approx(fd_result.value));
CHECK(g == approx(fd_result.derivative).epsilon(.01));
}
}
......
......@@ -16,7 +16,7 @@ TG_FUZZ_TEST(TypedGeometry, IntersectionRay3Sphere3)
auto result = tg::intersection(r, s);
CHECK(result.size() == 1);
CHECK(distance(result[0], s.center) == doctest::Approx(s.radius));
CHECK(distance(result[0], s.center) == approx(s.radius));
// inside (or on surface of) sphere moved along its direction
auto m = uniform(rng, box1).x * s.radius;
......@@ -28,7 +28,7 @@ TG_FUZZ_TEST(TypedGeometry, IntersectionRay3Sphere3)
result = tg::intersection(r, s);
CHECK(result.size() == 1);
CHECK(distance(result[0], r.origin) == doctest::Approx(s.radius - m));
CHECK(distance(result[0], r.origin) == approx(s.radius - m));
// close to surface and perpendicular shots
auto eps = tg::f32(1e-2);
......@@ -166,7 +166,7 @@ TEST_CASE("TypedGeometry.IntersectionSphere3Sphere3")
CHECK(res.has_value());
// radius is sqrt(1^2 - 0.5^2)
CHECK(res.value().radius == doctest::Approx(tg::sqrt(0.75f)));
CHECK(res.value().radius == approx(tg::sqrt(0.75f)));
// intersection circle center exactly between sphere centers
CHECK(res.value().center == tg::pos3(0, 0, 0.5));
......@@ -190,7 +190,7 @@ TEST_CASE("TypedGeometry.IntersectionSphere3Sphere3")
CHECK(res.has_value());
// radius is sqrt(1^2 - 0.5^2)
CHECK(res.value().radius == doctest::Approx(tg::sqrt(0.75f)));
CHECK(res.value().radius == approx(tg::sqrt(0.75f)));
// intersection circle center exactly between sphere centers
CHECK(res.value().center == tg::pos3(0, 0, 0.5));
......@@ -283,10 +283,10 @@ TEST_CASE("TypedGeometry.IntersectionCircle2Circle2")
CHECK(res.has_value());
// intersection positions
CHECK(res.value().first.x == doctest::Approx(0.5f));
CHECK(res.value().first.y == doctest::Approx(tg::sqrt(0.75f)));
CHECK(res.value().second.x == doctest::Approx(0.5f));
CHECK(res.value().second.y == doctest::Approx(-tg::sqrt(0.75f)));
CHECK(res.value().first.x == approx(0.5f));
CHECK(res.value().first.y == approx(tg::sqrt(0.75f)));
CHECK(res.value().second.x == approx(0.5f));
CHECK(res.value().second.y == approx(-tg::sqrt(0.75f)));
}
{ // intersecting circles (swapped circles)
......@@ -304,9 +304,9 @@ TEST_CASE("TypedGeometry.IntersectionCircle2Circle2")
CHECK(res.has_value());
// intersection positions
CHECK(res.value().first.x == doctest::Approx(0.5f));
CHECK(res.value().first.y == doctest::Approx(-tg::sqrt(0.75f)));
CHECK(res.value().second.x == doctest::Approx(0.5f));
CHECK(res.value().second.y == doctest::Approx(tg::sqrt(0.75f)));
CHECK(res.value().first.x == approx(0.5f));
CHECK(res.value().first.y == approx(-tg::sqrt(0.75f)));
CHECK(res.value().second.x == approx(0.5f));
CHECK(res.value().second.y == approx(tg::sqrt(0.75f)));
}
}
......@@ -12,12 +12,12 @@ TG_FUZZ_TEST(TypedGeometry, Determinant)
CHECK(determinant(mat) == 0.0f);
mat = tg::mat<D, D, tg::f32>::identity;
CHECK(determinant(mat) == doctest::Approx(1.0f));
CHECK(determinant(mat) == approx(1.0f));
auto rf = uniform(rng, rd1).x;
mat = tg::mat<D, D, tg::f32>::diag(rf);
auto res = tg::pow(rf, D);
CHECK(determinant(mat) == doctest::Approx(res));
CHECK(determinant(mat) == approx(res));
}
{
......@@ -27,12 +27,12 @@ TG_FUZZ_TEST(TypedGeometry, Determinant)
CHECK(determinant(mat) == 0.0f);
mat = tg::mat<D, D, tg::f32>::identity;
CHECK(determinant(mat) == doctest::Approx(1.0f));
CHECK(determinant(mat) == approx(1.0f));
auto rf = uniform(rng, rd1).x;
mat = tg::mat<D, D, tg::f32>::diag(rf);
auto res = tg::pow(rf, D);
CHECK(determinant(mat) == doctest::Approx(res));
CHECK(determinant(mat) == approx(res));
}
{
......@@ -42,12 +42,12 @@ TG_FUZZ_TEST(TypedGeometry, Determinant)
CHECK(determinant(mat) == 0.0f);
mat = tg::mat<D, D, tg::f32>::identity;
CHECK(determinant(mat) == doctest::Approx(1.0f));
CHECK(determinant(mat) == approx(1.0f));
auto rf = uniform(rng, rd1).x;
mat = tg::mat<D, D, tg::f32>::diag(rf);
auto res = tg::pow(rf, D);
CHECK(determinant(mat) == doctest::Approx(res));
CHECK(determinant(mat) == approx(res));
}
// random DxD matrices for 3D
......@@ -55,25 +55,25 @@ TG_FUZZ_TEST(TypedGeometry, Determinant)
auto matA = random_matrix<3>(rng);
auto matB = random_matrix<3>(rng);
// confirm multiplicativity
CHECK(determinant(matA * matB) == doctest::Approx(determinant(matA) * determinant(matB)).epsilon(0.01));
CHECK(determinant(matA * matB) == approx(determinant(matA) * determinant(matB)).epsilon(0.01));
matA = random_invertible_matrix<3>(rng);
matB = random_invertible_matrix<3>(rng);
// if invertible det != 0
CHECK(determinant(matA) != doctest::Approx(0.0f));
// CHECK(determinant(matB) != doctest::Approx(0.0f));
CHECK(determinant(matA) != approx(0.0f));
// CHECK(determinant(matB) != approx(0.0f));
// confirm multiplicativity
auto detA = determinant(matA);
auto detB = determinant(matB);
CHECK(determinant(matA * matB) == doctest::Approx(detA * detB));
CHECK(determinant(matA * matB) == approx(detA * detB));
auto invA = inverse(matA);
auto invB = inverse(matB);
CHECK(determinant(invA) == doctest::Approx(1.0f / detA));
CHECK(determinant(invB) == doctest::Approx(1.0f / detB));
CHECK(determinant(invA) == approx(1.0f / detA).epsilon(0.01));
CHECK(determinant(invB) == approx(1.0f / detB).epsilon(0.01));
}
// random DxD matrices for 2D
......@@ -81,24 +81,24 @@ TG_FUZZ_TEST(TypedGeometry, Determinant)
auto matA = random_matrix<2>(rng);
auto matB = random_matrix<2>(rng);
// confirm multiplicativity
CHECK(determinant(matA * matB) == doctest::Approx(determinant(matA) * determinant(matB)).epsilon(0.01));
CHECK(determinant(matA * matB) == approx(determinant(matA) * determinant(matB)).epsilon(0.01));
matA = random_invertible_matrix<2>(rng);
matB = random_invertible_matrix<2>(rng);
// if invertible det != 0
CHECK(determinant(matA) != doctest::Approx(0.0f));
CHECK(determinant(matB) != doctest::Approx(0.0f));
CHECK(determinant(matA) != approx(0.0f));
CHECK(determinant(matB) != approx(0.0f));
// confirm multiplicativity
auto detA = determinant(matA);
auto detB = determinant(matB);
CHECK(determinant(matA * matB) == doctest::Approx(detA * detB));
CHECK(determinant(matA * matB) == approx(detA * detB));
auto invA = inverse(matA);
auto invB = inverse(matB);
CHECK(determinant(invA) == doctest::Approx(1.0f / detA));
CHECK(determinant(invB) == doctest::Approx(1.0f / detB));
CHECK(determinant(invA) == approx(1.0f / detA));
CHECK(determinant(invB) == approx(1.0f / detB));
}
}
......@@ -22,16 +22,16 @@ TG_FUZZ_TEST(TypedGeometry, Norm)
auto v3 = uniform(rng, range3) - tg::pos3::zero;
auto v4 = uniform(rng, range4) - tg::pos4::zero;
CHECK(length(v1) == doctest::Approx(norm(v1, 2.f)));
CHECK(length(v2) == doctest::Approx(norm(v2, 2.f)));
CHECK(length(v3) == doctest::Approx(norm(v3, 2.f)));
CHECK(length(v4) == doctest::Approx(norm(v4, 2.f)));
CHECK(length(v1) == approx(norm(v1, 2.f)));
CHECK(length(v2) == approx(norm(v2, 2.f)));
CHECK(length(v3) == approx(norm(v3, 2.f)));
CHECK(length(v4) == approx(norm(v4, 2.f)));
}
{
auto p = uniform(rng, 1.0f, 10.0f);
CHECK(norm(tg::vec3::unit_x, p) == doctest::Approx(1.0f));
CHECK(norm(tg::vec4::unit_z, p) == doctest::Approx(1.0f));
CHECK(norm(tg::dvec2::unit_y, double(p)) == doctest::Approx(1.0f));
CHECK(norm(tg::vec3::unit_x, p) == approx(1.0f));
CHECK(norm(tg::vec4::unit_z, p) == approx(1.0f));
CHECK(norm(tg::dvec2::unit_y, double(p)) == approx(1.0f));
}
}
......@@ -4,14 +4,14 @@ TG_FUZZ_TEST(TypedGeometry, Rotation)
{
auto a = tg::degree(uniform(rng, 0.0f, 360.0f));
CHECK(frobenius_norm(rotation_x(a) - rotation_around(tg::dir3::pos_x, a)) == doctest::Approx(0.0f));
CHECK(frobenius_norm(rotation_y(a) - rotation_around(tg::dir3::pos_y, a)) == doctest::Approx(0.0f));
CHECK(frobenius_norm(rotation_z(a) - rotation_around(tg::dir3::pos_z, a)) == doctest::Approx(0.0f));
CHECK(frobenius_norm(rotation_x(a) - rotation_around(tg::dir3::pos_x, a)) == approx(0.0f));
CHECK(frobenius_norm(rotation_y(a) - rotation_around(tg::dir3::pos_y, a)) == approx(0.0f));
CHECK(frobenius_norm(rotation_z(a) - rotation_around(tg::dir3::pos_z, a)) == approx(0.0f));
auto v = tg::uniform<tg::dir3>(rng);
auto R1 = rotation_around(v, a);
auto R2 = rotation_around(-v, -a);
CHECK(frobenius_norm(R1 - R2) == doctest::Approx(0.0f));
CHECK(frobenius_norm(R1 - R2) == approx(0.0f));
CHECK(is_orthonormal(R1));
CHECK(is_orthonormal(R2));
......
......@@ -43,7 +43,7 @@ TG_FUZZ_TEST(TypedGeometry, Scaling)
auto l0 = length(v);
auto l1 = length(mat * v);
CHECK(l0 * r == doctest::Approx(l1));
CHECK(l0 * r == approx(l1));
}
{
auto mat = tg::scaling(tg::size2(r));
......@@ -53,7 +53,7 @@ TG_FUZZ_TEST(TypedGeometry, Scaling)
auto l0 = length(v);
auto l1 = length(mat * v);
CHECK(l0 * r == doctest::Approx(l1));
CHECK(l0 * r == approx(l1));
}
{
auto mat = tg::scaling(tg::size3(r));
......@@ -63,6 +63,6 @@ TG_FUZZ_TEST(TypedGeometry, Scaling)
auto l0 = length(v);
auto l1 = length(mat * v);
CHECK(l0 * r == doctest::Approx(l1));
CHECK(l0 * r == approx(l1));
}
}
......@@ -16,7 +16,7 @@ TG_FUZZ_TEST(TypedGeometry, Translation)
auto w = tra * v;
CHECK(w.x - v.x == doctest::Approx(s.x));
CHECK(w.x - v.x == approx(s.x));
}
// 2D
......
......@@ -33,7 +33,7 @@ TG_FUZZ_TEST(TypedGeometry, Area)
x *= randomScale;
const auto triangleArea = x * x / 2;
{
CHECK(triangleArea == doctest::Approx(area(triangle)));
CHECK(triangleArea == approx(area(triangle)));
}
// definitely smaller than aabb
......@@ -54,7 +54,7 @@ TG_FUZZ_TEST(TypedGeometry, Area)
auto equiTriangleArea = area(equiTriangle);
// the area of a nonrotated triangle is half the area of its aabb
CHECK(equiTriangleArea * 2.0f == doctest::Approx(area(aabb_of(equiTriangle))));
CHECK(equiTriangleArea * 2.0f == approx(area(aabb_of(equiTriangle))));
}
}
......@@ -88,7 +88,7 @@ TG_FUZZ_TEST(TypedGeometry, Area)
x *= randomScale;
const auto triangleArea = x * x / 2.0f;
CHECK(triangleArea == doctest::Approx(area(triangle)));
CHECK(triangleArea == approx(area(triangle)));
}
{
......@@ -97,19 +97,19 @@ TG_FUZZ_TEST(TypedGeometry, Area)
auto c = tg::cylinder3({0, 0, 0}, {0, h, 0}, r);
// surface area
CHECK(area(c) == doctest::Approx(h * 2 * r * tg::pi<tg::f32>.radians() + 2 * tg::pow2(r) * tg::pi<tg::f32>.radians()));
CHECK(area(c) == approx(h * 2 * r * tg::pi<tg::f32>.radians() + 2 * tg::pow2(r) * tg::pi<tg::f32>.radians()));
}
{
auto r = uniform(rng, box1).x;
auto d = tg::disk3({0, 0, 0}, r, tg::dir3::pos_y);
CHECK(area(d) == doctest::Approx(tg::pi_scalar<tg::f32> * tg::pow2(r)));
CHECK(area(d) == approx(tg::pi_scalar<tg::f32> * tg::pow2(r)));
}
{
auto r = uniform(rng, box1).x;
auto s = tg::sphere3({0, 0, 0}, r);
CHECK(area(s) == doctest::Approx(4 * tg::pi_scalar<tg::f32> * tg::pow2(r)));
CHECK(area(s) == approx(4 * tg::pi_scalar<tg::f32> * tg::pow2(r)));
}
{
......@@ -118,6 +118,6 @@ TG_FUZZ_TEST(TypedGeometry, Area)
auto pyra = tg::pyramid3(tg::rect3({0, 0, 0}, l), h);
// surface area
CHECK(area(pyra) == doctest::Approx(tg::pow2(l) + 4 * l * sqrt(tg::pow2(h) + tg::pow2(l / 2.0)) / 2.0));
CHECK(area(pyra) == approx(tg::pow2(l) + 4 * l * sqrt(tg::pow2(h) + tg::pow2(l / 2.0)) / 2.0));
}
}
......@@ -16,7 +16,7 @@ TG_FUZZ_TEST(TypedGeometry, BoxFuzz)
auto ob = tg::box3(ab);
CHECK(volume(ob) == doctest::Approx(volume(ab)));
CHECK(volume(ob) == approx(volume(ab)));
auto p = uniform(rng, ob);
CHECK(contains(ob, p));
......
......@@ -49,7 +49,7 @@ TG_FUZZ_TEST(TypedGeometry, Centroid)
{
auto surfacePoint = sphere.center + tg::vec3(tg::f32(cos(s) * sin(t) * radius), tg::f32(sin(s) * sin(t) * radius), tg::f32(cos(t) * radius));
CHECK(tg::distance_sqr(center, surfacePoint) == doctest::Approx(pow(radius, 2)));
CHECK(tg::distance_sqr(center, surfacePoint) == approx(pow(radius, 2)));
}
}
}
......
......@@ -10,8 +10,8 @@ TEST_CASE("object constants")
CHECK(centroid(tg::aabb3::unit_from_zero) == tg::pos3(0.5f));
CHECK(centroid(tg::aabb3::minus_one_to_one) == tg::pos3::zero);
CHECK(area(tg::sphere3::unit) == doctest::Approx(12.5663706));
CHECK(volume(tg::ball3::unit) == doctest::Approx(4.1887902f));
CHECK(area(tg::sphere3::unit) == approx(12.5663706));
CHECK(volume(tg::ball3::unit) == approx(4.1887902f));
CHECK(centroid(tg::sphere3::unit) == tg::pos3::zero);
CHECK(centroid(tg::ball3::unit) == tg::pos3::zero);
......
......@@ -16,8 +16,8 @@ TG_FUZZ_TEST(TypedGeometry, Coordinates)
auto coordinates = tg::coordinates(t, center);
// barycentric coordinates should all be the same for centroid
CHECK(coordinates[0] == doctest::Approx(coordinates[1]).epsilon(1e-3));
CHECK(coordinates[1] == doctest::Approx(coordinates[2]).epsilon(1e-3));
CHECK(coordinates[0] == approx(coordinates[1]).epsilon(1e-3));
CHECK(coordinates[1] == approx(coordinates[2]).epsilon(1e-3));
}
{
......@@ -30,10 +30,10 @@ TG_FUZZ_TEST(TypedGeometry, Coordinates)
// check for points in between if coordinates correct
auto s = uniform(rng, range1).x;
auto between = start + (end - start) * s;
CHECK(coordinates(l, between) == doctest::Approx(s));
CHECK(coordinates(l, between) == approx(s));
// start and end explicitly checked
CHECK(coordinates(l, end) == doctest::Approx(1));
CHECK(coordinates(l, start) == doctest::Approx(0));
CHECK(coordinates(l, end) == approx(1));
CHECK(coordinates(l, start) == approx(0));
}
}
......@@ -5,7 +5,7 @@ static void checkEqual(const tg::dir<D, ScalarT>& v0, const tg::dir<D, ScalarT>&
{
for (auto i = 0; i < D; i++)
{
CHECK(v0[i] == doctest::Approx(v1[i]).epsilon(eps));
CHECK(v0[i] == approx(v1[i]).epsilon(eps));
}
}
......
......@@ -14,8 +14,8 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto d2 = distance_sqr(a, b);
auto d = distance(a, b);
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// symmetry
CHECK(distance(b, a) == d);
CHECK(distance_sqr(b, a) == d2);
......@@ -27,8 +27,8 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto d2 = distance_sqr(a, b);
auto d = distance(a, b);
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// symmetry
CHECK(distance(b, a) == d);
CHECK(distance_sqr(b, a) == d2);
......@@ -40,8 +40,8 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto d2 = distance_sqr(a, b);
auto d = distance(a, b);
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// symmetry
CHECK(distance(b, a) == d);
CHECK(distance_sqr(b, a) == d2);
......@@ -55,12 +55,12 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto rd = tg::uniform(rng, rBox1).x;
auto b = a + dir * rd;
CHECK(distance(a, b) == doctest::Approx(tg::abs(rd)));
CHECK(distance(a, b) == approx(tg::abs(rd)));
auto d2 = distance_sqr(a, b);
auto d = distance(a, b);
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// symmetry
CHECK(distance(b, a) == d);
CHECK(distance_sqr(b, a) == d2);
......@@ -72,12 +72,12 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto rd = tg::uniform(rng, rBox1).x;
auto b = a + dir * rd;
CHECK(distance(a, b) == doctest::Approx(tg::abs(rd)));
CHECK(distance(a, b) == approx(tg::abs(rd)));
auto d2 = distance_sqr(a, b);
auto d = distance(a, b);
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// symmetry
CHECK(distance(b, a) == d);
CHECK(distance_sqr(b, a) == d2);
......@@ -89,12 +89,12 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto rd = tg::uniform(rng, rBox1).x;
auto b = a + dir * rd;
CHECK(distance(a, b) == doctest::Approx(tg::abs(rd)));
CHECK(distance(a, b) == approx(tg::abs(rd)));
auto d2 = distance_sqr(a, b);
auto d = distance(a, b);
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// symmetry
CHECK(distance(b, a) == d);
CHECK(distance_sqr(b, a) == d2);
......@@ -104,17 +104,17 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
{
auto p = uniform(rng, rBox1);
auto d = tg::distance_to_origin(p);
CHECK(d == doctest::Approx(tg::length(tg::vec1(p))));
CHECK(d == approx(tg::length(tg::vec1(p))));
}
{
auto p = uniform(rng, rBox2);
auto d = tg::distance_to_origin(p);
CHECK(d == doctest::Approx(tg::length(tg::vec2(p))));
CHECK(d == approx(tg::length(tg::vec2(p))));
}
{
auto p = uniform(rng, rBox3);
auto d = tg::distance_to_origin(p);
CHECK(d == doctest::Approx(tg::length(tg::vec3(p))));
CHECK(d == approx(tg::length(tg::vec3(p))));
}
......@@ -128,11 +128,11 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
// symmetry
auto d2 = distance_sqr(pt, pl);
auto d = distance(pt, pl);
CHECK(d == doctest::Approx(distance(pl, pt)));
CHECK(d2 == doctest::Approx(distance_sqr(pl, pt)));
CHECK(d == approx(distance(pl, pt)));
CHECK(d2 == approx(distance_sqr(pl, pt)));
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
// move point on plane
auto o = tg::pos3(pl.dis * pl.normal);
......@@ -143,11 +143,11 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
t = normalize(cross(pl.normal, r));
}
pt = o + t; // origin + tangent
CHECK(distance(pt, pl) == doctest::Approx(0.0f));
CHECK(distance(pt, pl) == approx(0.0f));
auto l = uniform(rng, rBox1).x;
pt += pl.normal * l; // move along normal
CHECK(distance(pt, pl) == doctest::Approx(tg::abs(l)));
CHECK(distance(pt, pl) == approx(tg::abs(l)));
}
......@@ -159,9 +159,9 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto pt = icone.apex - l * icone.opening_dir;
auto d2 = distance_sqr(pt, icone);
auto d = distance(pt, icone);
CHECK(d == doctest::Approx(l));
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d == approx(l));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
l = uniform(rng, 0.f, 10.f);
pt = icone.apex + l * icone.opening_dir;
d = distance(pt, icone);
......@@ -176,19 +176,19 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
pt = icone.apex + l * icone.opening_dir + r * ortho_dir;
d = distance(pt, icone);
d2 = distance_sqr(pt, icone);
CHECK(d == doctest::Approx(0).epsilon(0.01));
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d == approx(0).epsilon(0.01));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
d = distance(icone.apex, icone);
CHECK(d == doctest::Approx(0).epsilon(0.01));
CHECK(d == approx(0).epsilon(0.01));
pt = {2, -4, 0};
icone = tg::inf_cone3({0, 0, 0}, {0, 0, 1}, tg::angle::from_degree(90));
d2 = distance_sqr(pt, icone);
CHECK(d2 == doctest::Approx(10));
CHECK(d2 == approx(10));
l = uniform(rng, 0.f, 10.f);
pt = icone.apex + l * icone.opening_dir;
d = distance(pt, icone);
CHECK(d == doctest::Approx(l / sqrt(2)));
CHECK(d == approx(l / sqrt(2)));
}
......@@ -200,22 +200,22 @@ TG_FUZZ_TEST(TypedGeometry, Distance)
auto pt = sp.center + l * rand_dir;
auto d2 = distance_sqr(pt, sp);
auto d = distance(pt, sp);
CHECK(d == doctest::Approx(tg::abs(l - sp.radius)));
CHECK(d * d == doctest::Approx(d2));
CHECK(d == doctest::Approx(sqrt(d2)));
CHECK(d == approx(tg::abs(l - sp.radius)));
CHECK(d * d == approx(d2));
CHECK(d == approx(sqrt(d2)));
sp = tg::sphere<3, tg::f32>(tg::pos3(uniform(rng, rBox3)), uniform(rng, 0.f, 10.f));
pt = sp.center + sp.radius * rand_dir;
d = distance(pt, sp);
CHECK(d == doctest::Approx(0).epsilon(0.01));
CHECK(d