Is there a way (like planning algorithms) to draw a successive polyline to fill a specific shape (like triangle)?

there is a specific shape (like triangle) area, i am trying to develop an program to draw a successive polyline inside the triangle to fill the triangle, one line 3 layers

this post demonstrates some algorithms to solve this category of problems.

none of them is suitable for this task, any ideas?

• Why is this post tagged [machine-learning] and [deep-learning]? The problem can be solved using just [algorithms]. May 24, 2019 at 20:02
• CNC milling machines are programmed to execute solutions to this exact problem, but I do not know whether the machinist has to manually enter code to do the "hogging out", or if any of the programming languages have "meta" instructions to generate the needed low-level instructions. May 24, 2019 at 20:06
• 3-D printing software does have instructions to compile a 3-D shape file down to a series of low-level instructions to fill this kind of shape. Typically, the instructions generate parallel raster scan-lines, rather than modified triangles. May 24, 2019 at 20:09

Would not it be easier to simply apply geometric computation to your triangle to get smaller triangles whose vertices can be used for the polyline.?

With Wolfram Language

You have a triangle.

shp = Triangle[];
Graphics[{LightGray, shp}]


A ScalingTransform about the RegionCentroid can be performed with TransformedRegion to get smaller inner triangles. Below, shp is scaled by factors 0.8, 0.6, and 0.4 for the inner triangles.

scaledShps =
TransformedRegion[shp,
ScalingTransform[{#, #},
RegionCentroid@shp]] & /@ Range[.8, .4, -.2];
SeedRandom[456]
Graphics[{LightGray, shp, Riffle[Hue /@ RandomReal[1, Length@scaledShps], scaledShps]}]


Each of scaledShps has the vertices as the first argument. Map (/@) First to collect these and Flatten them into a single Line.

Graphics[{
LightGray, shp,
Orange, Thick, Line@Flatten[First /@ scaledShps, 1]
}]


Get more layers by increasing the number of scaling factors. For example, from .95 to .05 in steps of -.05

scaledShps =
TransformedRegion[shp,
ScalingTransform[{#, #},
RegionCentroid@shp]] & /@ Range[.95, .05, -.05];
Graphics[{
LightGray, shp,
Orange, Thick, Line@Flatten[First /@ scaledShps, 1]
}]


Wolfram recently released a free Wolfram Engine that can be called from many languages (Python, C, ...) so you can use the above code directly in your project.

Hope this helps.

• This algorithm is best-suited to convex shapes, such as triangles. If the shape is concave or contains holes, the shrunken shapes may cover areas that were not in the original shape. May 24, 2019 at 20:00