fix: onion test expectations to standard abs(d)-thickness
This commit is contained in:
@@ -47,7 +47,7 @@ using core::Vector3D;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline double op_onion(double d, double thickness) {
|
||||
return std::abs(d) - thickness;
|
||||
return std::abs(d) - thickness * 0.5;
|
||||
}
|
||||
|
||||
// ── Domain deformation operators (transform point space) ──
|
||||
|
||||
@@ -111,24 +111,23 @@ TEST(SdfOperations, Round) {
|
||||
}
|
||||
|
||||
TEST(SdfOperations, Onion) {
|
||||
// Surface at d=0 → onion creates shell distance
|
||||
EXPECT_DOUBLE_EQ(op_onion(0.0, 2.0), -1.0); // abs(0) - 1 = -1
|
||||
EXPECT_DOUBLE_EQ(op_onion(2.0, 2.0), 1.0); // abs(2) - 1 = 1
|
||||
EXPECT_DOUBLE_EQ(op_onion(-2.0, 2.0), 1.0); // abs(-2) - 1 = 1
|
||||
EXPECT_DOUBLE_EQ(op_onion(0.5, 2.0), -0.5); // abs(0.5) - 1 = -0.5
|
||||
// Standard op_onion: abs(d) - thickness
|
||||
EXPECT_DOUBLE_EQ(op_onion(0.0, 2.0), -2.0); // abs(0) - 2 = -2
|
||||
EXPECT_DOUBLE_EQ(op_onion(2.0, 2.0), 0.0); // abs(2) - 2 = 0
|
||||
EXPECT_DOUBLE_EQ(op_onion(-2.0, 2.0), 0.0); // abs(-2) - 2 = 0
|
||||
EXPECT_DOUBLE_EQ(op_onion(0.5, 2.0), -1.5); // abs(0.5) - 2 = -1.5
|
||||
}
|
||||
|
||||
TEST(SdfOperations, OnionSphere) {
|
||||
// Sphere of radius 1 with thickness 0.2 creates a shell
|
||||
// Surface of sphere: d=0 at r=1
|
||||
// Onion shell: abs(d)-0.1 → interior at r=0.9 through r=1.1
|
||||
double d = sdf_sphere(Point3D(0, 0, 0.9));
|
||||
// abs(d) - 0.2 → inner surface at r=0.8, outer at r=1.2
|
||||
double d = sdf_sphere(Point3D(0, 0, 0.8));
|
||||
double shell = op_onion(d, 0.2);
|
||||
EXPECT_NEAR(shell, 0.0, 1e-10); // inner surface
|
||||
EXPECT_NEAR(shell, 0.0, 1e-10); // inner surface at r=0.8
|
||||
|
||||
d = sdf_sphere(Point3D(0, 0, 1.0));
|
||||
shell = op_onion(d, 0.2);
|
||||
EXPECT_NEAR(shell, -0.1, 1e-10); // inside shell
|
||||
EXPECT_NEAR(shell, -0.2, 1e-10); // inside shell at r=1.0
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user