this is a bit of a follow-up of the discussion here: “perfect” grid with nice boundary
I was playing around with brick patterns for arbitrary shapes and ran into a problem when trying to layout a pattern on a tapered part:
Any idea how to avoid these “horrible” aligning lines? My goal is to have a nicer pattern and accept a little more variance in the spacing of the points / “bricks”. For this simple part its not one can just always use the same number of bricks per row:
I made a brick placer time ago…
It was with unconstant brick size (they were scrap pieces) and so even for straight walls some addittional logic was needed
I had some luck in trying with random placement!
From a “pool” of bricks (List of numbers), the function
1- picked up bricks until the distance to cover was reached (adding a “gap” for each brick)
2- check if the overlaps with previous row was ok, if not, jitter the list and try again
3- if after 10 jitters it still fails, put all the bricks of last row to the pool, jitter the pool, and back to pt 1.
It was working incredibly fast, as the cpu can try countless attempts in a fraction of a second.
The results were so good that it surprised me. Making a “conscious” algorithm for placing would have been 100x time expensive…
Note: if the total space to cover was X , the sum of the brick size in the pool needed to be at least 1.3*X or such.
In your case.
Are all the bricks the same size?
Do you want the gaps in the same row to have all the same width?
If both yes, i throw out a “impossible to find a solution” … imho
I iterate over all layers sequentially, starting in with the first layer
( first layer: divide layer curve in N segments)
pull points from lower layer to current layer
check distances: if the distances in the current layer between each point are within the limit specified by up&lowLimit create line segment (polyline) between the points. Due to the pulling of the points from the lower layer the distances between the points can vary.
refinement: if there are any gaps between the line segments , create new polylines with more evenly spaced points between.