fix: correct vertex singularity detection in computeSingularityTerms#52
Conversation
…rity casefix: check existing installations
|
Thanks for reaching out and opening a PR. The reason that The extra condition for case 2 is definitely a good addition. For the floating point comparison, I am thinking of inroducing some sort of Otherwise, the question is, anyway, how much we can fix this. Because with any Anyways, I would leave this PR open for now until we have a full fix and will continue here next week (have other todos around my ears as well unfortunatley) Tetrahedron Potential Evaluation — Before vs. FixEach block lists the calculation point P and the resulting potential, for the P = [10, 0, 1e-13]potential =
P = [10, 0, 1e-14]potential =
P = [10, 0, 1e-15]potential: before =
P = [10, 0, 1e-16]potential =
P = [10, 0, 0]potential =
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary
computeSingularityTermsto select the edge singularity path (Case 2) instead of the vertex singularity path (Case 3) for query points whose projection P' lands at a face vertex.== 0.0comparison inconsistent with the< EPSILON_ZERO_OFFSETthreshold used everywhere else in the function.Root cause
When P' projects onto a vertex, floating-point arithmetic produces
rvn[(j+1)%3] ≈ ~|G| - epsinstead of exactly|G|. This satisfies the Case 2 conditionrvn < |G|, firing the edge singularity formula-pi * h_pinstead of the correct vertex formula-theta * h_p.Changes
>= EPSILON_ZERO_OFFSETon both vertex-distance norms so near-vertex points (norm < ε) fall through to Case 3.r1Norm == 0.0withr1Norm < EPSILON_ZERO_OFFSETfor consistency with the rest of the function.Verification
Create a right-angle tetrahedron with vertices
(0,0,0),(2,0,0),(0,2,0),(0,0,2)and query point(10, 0, z).Changing z and comparing the potential produced by original vs fixed you obtain:
Discontinuities are highlighted in bold.
All existing tests pass.
Remaining bugs!!!
z = 1e-14shows a pre-existing discontinuity in both the original and fixed code, which I was not able to fix. It could be related withEPSILON_ZERO_OFFSETbeing exactly1e-14