I have a simple algorithm that fails sometimes because it is comparing doubles. I look at a DXF drawing and get all the line segments, and also break it down into a series of points. When looping through all the points to identify if it forms a cycle (ie if a line touches, I should get 2 hits on a point) and inspecting the output they are close. So sometimes this algorithm and the equals with a delta comparison method gets a pass, then sometimes it fails...
So how close should a point be to consider it the same point or overlapping?
These should be the same, but then i think rounding happens and the numbers slightly adjust based on what I set the tolerance too making it sometimes equal and sometimes not..
Point: [4.6408, 14.8708] Point: [4.6799, 14.8156]
Even though it's a DXF file it doesn't seem to be exact or setup in a way to get identical values they are extremely approximate and fine grained, so I am not even sure how the DXF file itself works because when you use a drawing program you can make a distinct line entities that actually touch each other and the UI snaps the lines together...so should I compare it to one decimal place only? No decimal places?
I guess the issue is these drawings are made from a variety of different programs in a variety of different ways, maybe the DXF file format has something else I can inspect to identify this? For now I am doing it this way and it seems "buggy".
Any thoughts or suggestions? I do have a comparison / equals method that takes a tolerance, should I just make it really tight?
Thanks,