Drawing semi-randomly placed squares of various size and rotation
in
Programming Questions
•
2 years ago
Hi Everyone,
I wonder if someone can help me here. I am new to Processing. The following is a subset of a problem I am working on, and I hope that if someone can show me how to solve it, then I can work out the solution to the whole problem.
* I need to draw N squares on the screen (where N may be 1 to 25).
* The centre a given square is one of the corners of a 4 by 4 grid.
* The length of each square in this grid is G, so that the total length of the grid is 4G.
* To ensure non-overlapping squares, the maximum length of a given square is L = G/sqrt(2)
* The actual length of each drawn square is a random number from 0 to L.
* The rotation of each square drawn is random.
* No square may share the same centre (grid point).
Please see the diagram below for a visual aid.
I wonder if someone can help me here. I am new to Processing. The following is a subset of a problem I am working on, and I hope that if someone can show me how to solve it, then I can work out the solution to the whole problem.
* I need to draw N squares on the screen (where N may be 1 to 25).
* The centre a given square is one of the corners of a 4 by 4 grid.
* The length of each square in this grid is G, so that the total length of the grid is 4G.
* To ensure non-overlapping squares, the maximum length of a given square is L = G/sqrt(2)
* The actual length of each drawn square is a random number from 0 to L.
* The rotation of each square drawn is random.
* No square may share the same centre (grid point).
Please see the diagram below for a visual aid.
1