This may be a result of an oversight I made. For small triangles the algorithm might find a false hit. Try replacing

# 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

by (here RTOL should be something like 1e-4, adjust to taste)

# 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

Edited 4 time(s). Last edit at 2013-03-14 03:44PM by Tim Gould.