fix(sdf): S12-A test_gradient — fix includes and remove Eigen gtest streaming
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
#include "vde/sdf/sdf_gradient.h"
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <random>
|
||||
|
||||
#include <vector>
|
||||
using namespace vde::sdf;
|
||||
using vde::core::Point3D;
|
||||
using vde::core::Vector3D;
|
||||
@@ -213,7 +212,7 @@ TEST(SdfAnalytic, SphereAgreesWithFd) {
|
||||
Vector3D g_analytic = sphere_gradient_analytic(p, 2.0);
|
||||
Vector3D g_fd = gradient(f, p, FD_H);
|
||||
double diff = (g_analytic - g_fd).norm();
|
||||
EXPECT_LT(diff, EPS_LOOSE) << " at point " << p.transpose();
|
||||
EXPECT_LT(diff, EPS_LOOSE) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +228,7 @@ TEST(SdfAnalytic, BoxAgreesWithFd) {
|
||||
Vector3D g_fd = gradient([&](const Point3D& pt) { return box(pt, extents); }, p, FD_H);
|
||||
// Near edges/corners the analytic gradient differs from FD due to non-smoothness
|
||||
double diff = (g_analytic - g_fd).norm();
|
||||
EXPECT_LT(diff, 0.5) << " at point " << p.transpose();
|
||||
EXPECT_LT(diff, 0.5) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +242,7 @@ TEST(SdfAnalytic, TorusAgreesWithFd) {
|
||||
Vector3D g_analytic = torus_gradient_analytic(p, 2.0, 0.5);
|
||||
Vector3D g_fd = gradient(f, p, FD_H);
|
||||
double diff = (g_analytic - g_fd).norm();
|
||||
EXPECT_LT(diff, EPS_LOOSE) << " at point " << p.transpose();
|
||||
EXPECT_LT(diff, EPS_LOOSE) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +256,7 @@ TEST(SdfAnalytic, CylinderAgreesWithFd) {
|
||||
Vector3D g_analytic = cylinder_gradient_analytic(p, 1.0);
|
||||
Vector3D g_fd = gradient(f, p, FD_H);
|
||||
double diff = (g_analytic - g_fd).norm();
|
||||
EXPECT_LT(diff, EPS_LOOSE) << " at point " << p.transpose();
|
||||
EXPECT_LT(diff, EPS_LOOSE) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +284,7 @@ TEST(SdfAnalytic, CapsuleAgreesWithFd) {
|
||||
Vector3D g_analytic = capsule_gradient_analytic(p, a, b, 0.5);
|
||||
Vector3D g_fd = gradient(f, p, FD_H);
|
||||
double diff = (g_analytic - g_fd).norm();
|
||||
EXPECT_LT(diff, EPS_LOOSE) << " at point " << p.transpose();
|
||||
EXPECT_LT(diff, EPS_LOOSE) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,7 +527,7 @@ TEST(SdfGradient, SphereGradientMagnitude) {
|
||||
};
|
||||
for (const auto& p : pts) {
|
||||
Vector3D g = gradient(f, p, FD_H);
|
||||
EXPECT_NEAR(g.norm(), 1.0, EPS_LOOSE) << " at " << p.transpose();
|
||||
EXPECT_NEAR(g.norm(), 1.0, EPS_LOOSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,7 +541,7 @@ TEST(SdfGradient, BoxGradientMagnitudeOutside) {
|
||||
for (const auto& p : pts) {
|
||||
Vector3D g = gradient(f, p, FD_H);
|
||||
// Exterior gradients should have unit magnitude (away from edges)
|
||||
EXPECT_NEAR(g.norm(), 1.0, 0.05) << " at " << p.transpose();
|
||||
EXPECT_NEAR(g.norm(), 1.0, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,7 +553,7 @@ TEST(SdfGradient, TorusGradientMagnitude) {
|
||||
};
|
||||
for (const auto& p : pts) {
|
||||
Vector3D g = gradient(f, p, FD_H);
|
||||
EXPECT_NEAR(g.norm(), 1.0, EPS_LOOSE) << " at " << p.transpose();
|
||||
EXPECT_NEAR(g.norm(), 1.0, EPS_LOOSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user