Thursday, November 11, 2010

Imaging and Transformation

Well, I decided to get an easier interface with the imaging library I'm using. I was just calling a function I had made before that accepted two arrays and a name for a file to be saved too. But I decided I'd like to have my graphs plotted like they're graphs. So I created a class that would accept a size (x by y) for a pane to draw to, and a coordinate system to use. 'c' for Cartesian, 'a' for absolute. Cartesian is the coordinate system you normally use, where there are 4 quadrants and it's pretty simple to plot. Absolute is how the computer really plots pixels, from the top left. There is no negative positions, only positive going eastward from the top left as x, and southward from the top left as y.

It was really simple to figure out how to transform coordinates in absolute to Cartesian. You simply take the of your pane, divide it by 2, and those (x,y) points are your origin. So when you receive absolute positions from the user, you simple do originX + incomingX and originY - incomingY. It's really simple! I was pretty happy at how well it worked out.

So I also made a couple functions to draw a Grid to the pane so you can see your lines with the axes and graph paper like quality, or just the axes. It's great! And it makes seeing my recursive solutions from my other program really easy!

My next project is to make an ongoing simulation where you can give the program points to go after loading up a maze of obstacles, set a start point and ask it to go places. If I can get that working, then I can move on to try to get some image processing to process images of streets and other things, and allow a user to flag things as obstacles and the program suggest ways to go about getting around them.
My Ultimate goal is to make it completely automated, flagging obstacles by itself and coming up with the best strategy to attack the problem, or suggesting multiple strategies. And from there, having it compute how 2 objects could work together to outflank anything behind the obstacles. Basically, a very basic tactical advisory unit. Or as my project folder is called, TAU.
Solution plotted with Grid
Solution plotted without
grid but with axes
Just the grid being displayed
mission accomplished!

No comments:

Post a Comment