fix: SDF nan/edge cases + B-Rep vertex index → ID fix + IGES 1-based DE + STEP cleanup
This commit is contained in:
@@ -46,7 +46,12 @@ using core::Vector3D;
|
||||
[[nodiscard]] inline double capsule(const Point3D& p, const Point3D& a, const Point3D& b, double radius) {
|
||||
Point3D pa = p - a;
|
||||
Point3D ba = b - a;
|
||||
double h = std::clamp(pa.dot(ba) / ba.squaredNorm(), 0.0, 1.0);
|
||||
double ba_sq = ba.squaredNorm();
|
||||
if (ba_sq < 1e-30) {
|
||||
// Degenerate to sphere
|
||||
return pa.norm() - radius;
|
||||
}
|
||||
double h = std::clamp(pa.dot(ba) / ba_sq, 0.0, 1.0);
|
||||
return (pa - ba * h).norm() - radius;
|
||||
}
|
||||
|
||||
@@ -75,6 +80,10 @@ using core::Vector3D;
|
||||
double k1 = Point3D(p.x() / (radii.x() * radii.x()),
|
||||
p.y() / (radii.y() * radii.y()),
|
||||
p.z() / (radii.z() * radii.z())).norm();
|
||||
if (k1 < 1e-30) {
|
||||
// Degenerate: point at origin → distance = -min(radii)
|
||||
return -std::min({radii.x(), radii.y(), radii.z()});
|
||||
}
|
||||
return k0 * (k0 - 1.0) / k1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user