You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So currently I've invented in my had a small algorithm to split rectangle on a list of random rectangles. At first I had in mind simple one (which is still a backup plan):
Split rectangle on two with either vertical or horizontal line.
Continue that for both subrectangles.
Continue 1. and 2. until some point of time
But I don't like the limitation of rectangle splitting. Because is too clumsy. It looks like you hack each rectandles on two parts every time. Which is too obvious.
So my algorithm is next:
Pick a pixel in the edge of rectangle
Start drawing line from it, perpenicular to the starting edge.
Proceed to the other edge on stop between them
If you stopped in the middle, start emit two line in one of sides (left, right, top, bottom) except the side of original line.
For each line continue either to the edge or already draw line; or stop in the middle
Continue 4 and 5, until the is no "middle" lines left
With this algorithm it is possible to draw something like:
_________
| |______|
|__|___| |
|______|__|
Which is not possible with first algorithm. Moreover second one extend the first one in terms of number of possibilities
The text was updated successfully, but these errors were encountered:
So currently I've invented in my had a small algorithm to split rectangle on a list of random rectangles. At first I had in mind simple one (which is still a backup plan):
Split rectangle on two with either vertical or horizontal line.
Continue that for both subrectangles.
Continue 1. and 2. until some point of time
But I don't like the limitation of rectangle splitting. Because is too clumsy. It looks like you hack each rectandles on two parts every time. Which is too obvious.
So my algorithm is next:
Pick a pixel in the edge of rectangle
Start drawing line from it, perpenicular to the starting edge.
Proceed to the other edge on stop between them
If you stopped in the middle, start emit two line in one of sides (left, right, top, bottom) except the side of original line.
For each line continue either to the edge or already draw line; or stop in the middle
Continue 4 and 5, until the is no "middle" lines left
With this algorithm it is possible to draw something like:
Which is not possible with first algorithm. Moreover second one extend the first one in terms of number of possibilities
The text was updated successfully, but these errors were encountered: