Key to getting from 540 triangles to 516 was setting a reasonable threshold (<0.00000001) and then checking the degree to which the points on a candidate triangle came to achieving equality in the triangle inequality. (https://en.wikipedia.org/wiki/Triangle_inequality)