This may be a result of an oversight I made. For small triangles the algorithm might find a false hit. Try replacing
by (here RTOL should be something like 1e-4, adjust to taste)
Code:
# O (N_Edges N_Points)
for I,J in Edges
for K in Points
DIJ=Dist(P(I),P(J))
DIK=Dist(P(I),P(K))
DJK=Dist(P(I),P(K))
if (abs(DIJ-(DIK+DJK))<TOL)
# K is on the line between I & J
PushLineTrio(I,J;K)
endif
endfor
endfor
Code:
# O (N_Edges N_Points)
for I,J in Edges
for K in Points
DIJ=Dist(P(I),P(J))
DIK=Dist(P(I),P(K))
DJK=Dist(P(I),P(K))
if ((abs(DIJ/(DIK+DJK)-1.0)<RTOL) && (abs(DIJ-(DIK+DJK))<TOL))# CHANGED TO INCLUDE A RELATIVE CHECK TOO
# K is on the line between I & J
PushLineTrio(I,J;K)
endif
endfor
endfor