The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
I have been working on and off (at home) on that single algorithm for almost 2 and half years, I think.
I am now very close to completion with an elegantly simple algorithm
Except.. it doesn't work...
After days of staring at my screen I came up with a test that shows an internal data inconsistency that will predict failure.
But... basically the validation is a loop doing some calculation at each step.. .
It came literally right after the same loop applying the calculation result.. yet it has different value than expected?!
Why, ho why? And how?
I think the forces that be are preventing me from finding the truth!
That's the only logical explanation I can come up with!
The problem with stepping through the whole algorithm manually is that there is too much data and raw numerical values don't make much sense to human eyes... it describe 2 potatoes intersection.. but when I look at the bezier's handle point values, it means little to me (except visually..)
FYI, trying to debug this vector graphic eraser issue
Anyway, just made a tiny bit more progress... In my structure I got, for some reason, an odd number of intersection (between 2 shapes)...
in all seriousness, I just got done with tackling a similar debugging issue.
Sometimes the debugger just isn't enough. As another commenter pointed out, the algorithm doesn't usually make much sense to people once it's at the point where it breaks.
So you should write more code. I dumped intermediary LALR tables to CSV for example so i could visualize them. I also made symbols and grammar rules print out string representations of themselves to the debugger to help.
In the end, write MOAR CODE until the problem reveals itself.
Sometimes using graphviz can help, in extreme cases.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
Yeah I made (some tiny bit) of progress lately.. because I wrote plenty of tools and visualisation to make the issue more understandable...
I am getting close.. When it fails I got 3 intersection between 2 shapes (best understanding, so far, about the problem) now I just have to find out why!
That can't be.. I guess I misdiagnosed a touch for an intersection.... That's a tricky one, since intersection are approximation though...
In my past I did a lot of geometric programming. Something we had to be be very careful of was degenerate intersections and numerical tolerance. That is the first thing I thought of when you mentioned an odd number of intersections. If you are at or very close to the endpoint of a line segment, it might miss, or hit, when it really shouldn't.
Sometimes you have to catch them and handle them specially (*cough* hack *cough*). Like artificially extend the vector slightly to see if it intersects within the segment, or keep intersections that are questionable conditional until you can tell the count is right. For instance, imagine two line segments whose common endpoint is on or very close to the segment you are intersecting with. Really, there should be only one intersection there. But if you count each segment endpoint as colliding, then you get two intersections where you should have only one. Or vice versa, you might discard both because you think they are off the line, and have zero where you should have one.
Sorry, this is off the top of my head remembering stuff we had to deal with a long time ago.
Hey I am pretty sure it is such error.. it only happen (so far as I know) with 2 almost parallel shape and one with 1 very small edge...
Anyhow can't do anything more about this week, preparing a table top RPG adventure..
But gods this is so frustrating...
For the record to get around such issue I merge many point that I found close to each other, nudging them slightly.. But that is not enough... Now I also use smarter crossing edge detection at intersection, still not enough..
That's how I have solved some knotty issues with a Python bouncy ball simulation I have been writing(just because I wondered what all the hype about Python has been).
I created a logger class and wrote all the data out to a tab delimited file.
I then found fairly quickly where the issues were - as rather than see isolated data, which is what debugger information tends to present, I was able to see data over time and solve the problem from there.
“That which can be asserted without evidence, can be dismissed without evidence.”