Archive for December, 2007

Santa Dropped off a QCR Solution

Sunday, December 30th, 2007

I ran into three big problems over breaking working on the angle following portion of QCR.  First I wanted to allow each region to support following multiple edges.  I also wanted every point to be able to split in every possible growth direction.  Both these problems were mentioned in earlier versions of the software as things that should be corrected.   Before because of the “everything is a special case” 1.5k lines of code growth methods these were almost impossible to change.  Now with the new simplified growth conditions these became much easier to implment by allowing the program to split any point on the region into a new edge when it collides with a positive space region.   Both edge points on each edge are now tested.

The third problem was the big one.  I was having trouble figuring out where to place the end points of the lines for the edge following condition.  Before I used knowledge gained from having a bunch of special cases since I would know which case I was in and could make assumptions from that about the direction of growth.  Since I no longer have special cases for each growth direction I needed a general solution that could handle any case.

The solution I have devised is pretty simple and took a stupidly long time to figure out
Insert into Notebook which was stupidly left at charlotte:
While edge following.
Known:  Equation of line you are following,  Direction of normal growth,  Current Points,  Which endpoint is in edge follow mode(both can be now if so you have two of everything related to line following), Endpoint of line we are following.

Algorithm:
1. Pretend like you were doing normal direction growth and generate tempary points there.
2. Use the edge you generated in step one and take the equation of the line you wish to follow.  Find the point where they intersect.  This point will be within the line generated by normal growth(Or things are convex which is a problem that should already have been caught).
3.  Look at the two points that you generated in step 1.  Since this line is axis aligned one of the values(X,Y) will be the same in both of them.  Replace the unique value of the point that is contour following with the equivalent value from the intersection point generated in step 2.
4.   Make sure you haven’t exceeded the line you are trying to follow(return impossible to grow if so).
5.  Return new edge.
*If both points are in  edge following mode find two intersection points(using both contour tracing lines) and replace a portion of both values from the the correct intersection point.
6.  Give thanks to the many pieces of copy paper that gave there lives to figure this out.  Also for the house finally getting empty so I could work for more than 10 minutes without an interruption.

Implementation should be easy and it will be a lot less lines so less to go wrong and debug.  With a little luck this will be done tonight if not then tomorrow.

Hunter

Out with the old in with the new.

Thursday, December 6th, 2007

Its amazing what you can do when you are willing to toss out what you have been working on.  Dumping 2k lines of spagattie code that was impossible to debug without introducing more bugs and replacing it with 100 lines of good code and a couple helper classes is having an amazing effect.  I should have done this like 2 months ago as soon as I had the algorithm finalized.  I was using a unique point based approach that looked like it would work at the beginning but didn’t.  The correct approach is to look at things by edges and to connect the edges using pointers to a common endpoint.  At current rate of progress I should have the entire thing up and running by monday no problem sure will be nice to get ahead of a deadline for change.  This will also mean I can demo for that video submission thing with my new code base and be ready to make the jump to 3D over christmas.  I am thinking i will want to use planes in lue of edges for that.  The big change was switching out the maze of special case statements and designing a smart class that can just grow in the direction it needs to.  Extending the base drawing classes to use floats instead of ints is also helping even if it involved a bit more coding.