I need a program written in C# which should do the following thing:
At the input we have the file "input.txt" in the following format
N, A, B
N - the number of rectangles
A- the length of the first edge of the rectangle (integer not larger than 50 and not smaller than 5)
B- the length of the second edge of the rectangle (integer not larger than 50 and not smaller than 5)
1. The program should place at randomly chosen positions N rectangles with edges with length A and B at randomly chosen positions. All coordinates of vertices of rectangles should be integers not larger than 800 (this number should be the parameter of the program) and not smaller than 1. Rectangles can overlap. Rectangles have red color and are placed at the initially blue square with the edge with length 800.
2. We will say that a point P is of type 1 if it is possible to go from the left edge of the square to the right edge of the square trough any path without crossing any red points. Points situated within the square of length 800 for which it is not possible and all points situated are called "points of type 0".
3. Points of type 0 are separated from the points of type 1 by a set of polygons. The program should find all these polygons. The file "output.txt" should be produced which should be in the following format:
The first line should contain the number of polygons.
The format of next lines should be following
NV, X1, Y1, X2, Y2, ...
where NV - the number of vertices, X1, Y1- the first and the second coordinate of the first vertex of the polygon,...
4. Program should visualize results producing the figure at which rectangles found in point 1 should be drawn with red color and polygons separating regions of type 1 from regions of type 0 should be drawn with black color.
The program should work in reasonable time - let us say that at least for parameters of type N=640, A=B=10 it should not work longer than about 6 hours on a typical PC.
The project in principle concerns above described problem with rectangles, however let me know if you are able within the budget to write analogous program for
I want to clarify the above description:
1. The last sentence in the point 2 should be "Points situated within the square of length 800 for which it is not possible and all points situated OUTSIDE THE 800x800 SQUARE" are called "points of type 0".
2. By "any path" in the point 2 I mean any curve which doesn't cross red points and goes trough the point P. If it isn't clear enough: Let us imagine that into the square flows liquid trough the left edge of 800*800 square. The point P is of type 1 if the liquid in principle can reach the point P and then leave the large square trough the right edge.
3. Please note that the problem is a bit more difficult that just finding polygons which separate points of type 1 from points of type 0 (see attached pdf).
4. For me it is satisfactory if rectangles which are placed randomly in the point 1 have edges which are parallel to the edges of 800*800 square.
5. To clarify the problem I attach the file Example.pdf. In this file 800*800 square has grey color (instead of blue mentioned in point 1), however it doesn't matter of course. The program should produce the list of vertices of polygons which are drawn with the yellow color.