I am making a voxel game and creating the terrain, The ground and elements on it are rectangles,
First of all I want to generate the elements guaranteed that their total area is less than ground space.
in one dimensional space I figured ways to do so but couldn't apply any of them on 2d, on of them is get the sum of remaining length and place elements with some spacing while my left space is decreasing.
I tried another way by dividing the ground rect to smaller rects but it doesn't fit my needs.
One possible way,
This way you can generate rectangles that don't overlap and the sum of areas is less than the total area.
If you want the rectangles to be at different angles, then a similar approach can be used. Just the difference is that you will have to generate an extra number specifying the angle of the edge.