Is there a way (like planning algorithms) to draw a successive polyline to fill a specific shape (like triangle)?
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]] &amp; /@ 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]] &amp; /@ 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.