Area Separation Algorithm

Is there any algorithm for finding the distribution of a region in n subregions, where each subdomain can have a different region.

To formally pose the problem operator: suppose you have a rectangular graph. How do you divide an area into n rectangles. The sum of the area of ​​these sub-rectangles will be equal to the original rectangular graph (so there would be no coincidence between the rectangles) And the area of ​​each of these smaller n rectangles is given in front of the hand. The restriction is made according to the width of each sub-rectangle. This unit should be displayed on a computer screen, which is divided into pixels. Therefore, I do not want any dimension to be smaller than a pixel (or maybe 10) in any areas, which can be useless to display as such.

I looked at the rectangle packing algorithm here , but it seems to be wasting space that I don't want. Is there any algorithm to solve this problem.

Backtracking does not seem to be a good solution in this case, since the area under the rectangles is indicated only, not the dimensions, or is it?

Example 1: enter image description here

Example 2: enter image description here

+4
source share
1 answer

The integral of a function is the area connected by the boundaries, the curve of the function, and the x axis. Define one side of the rectangle as the x axis, then find the borders for the rest. There are many digital integration libraries in your chosen language.

EDIT: some difficulties in trying to illustrate with words ...

Assuming at least that the containing rectangle has an area larger than the sum of the regions of the subregions; and there is no requirement for a specific deterrence order:

  • Contains the largest subregion first with ribs on the axes.
  • Choose the next smaller subregion.
  • Create a function (integral) to calculate the free area, as seen from each axis.
  • With windows / limits equal to the length on the sides of the subregion (facing the axes), shift these windows along the axes from the origin.
  • Create a function to find the free space bounded by the external levers of the cross formed by the windows as they slide along the axes. Space efficiency is in an area where free space is minimal (differentiation).
  • Subregion rotates 90 degrees and repeats from step 3.
  • Place the subregion in the position and place where it is most effective.
  • Repeat step 2. Stop when sliding windows report negative.

free space for the entire domain (the allocated space overlaps the placeholder made by windows).

In theory, this will systematically attempt to squeeze in subregions. Sketch and pseudo code should follow if time permits.

0
source

Source: https://habr.com/ru/post/1380054/


All Articles