Uniform Subdivision of Equilateral Triangle

Just adding to the resource :slight_smile:
Modified the definition to process a list of equilateral triangle surfaces of different sizes
equilateralSubDivision1.dyn (5.3 KB)

The above code fails when the number of sub divisions is less than 2.
Here is a rectified version that addresses the issue ā€¦

//Edges of equilateral surface
crv1=tri.PerimeterCurves();
len1=List.GetItemAtIndex(crv1<1>,0).Length;
n=d<1?1:d;
len2=len1/n;

//Vertices of equilateral surface
pnt1=List.GetItemAtIndex(crv1<1>,0).StartPoint;
pnt2=List.GetItemAtIndex(crv1<1>,1).StartPoint;
pnt3=List.GetItemAtIndex(crv1<1>,2).StartPoint;

dir1=Vector.ByTwoPoints(pnt1,pnt2);
dir2=Vector.ByTwoPoints(pnt1,pnt3);
dir3=Vector.ByTwoPoints(pnt2,pnt3);

//Sub triangle 1
pnt4=pnt1.Translate(dir1,len2);
pnt5=pnt1.Translate(dir2,len2);
sub1=Polygon.ByPoints(Transpose({pnt1,pnt4,pnt5}));

//Repeating sub triangle
n2=(0..(n-1))*len2<1>;
sub2=sub1.Translate(dir1,n2);
n3=List.TakeItems(n2<1>,1..n);
sub3=sub2.Translate(dir3,n3);

//Sub triangle 2
pnt6=n<2?pnt1:pnt4.Translate(dir2,len2);
sub4=Polygon.ByPoints(Transpose({pnt4,pnt5,pnt6}));
n4=(0..(n-2))*len2<1>;
sub5=sub4.Translate(dir1,n4);
n5=List.TakeItems(n4<1>,1..n);
sub6=sub5.Translate(dir3,n5);

srf1=Display.ByGeometryColor(sub3.Patch(),Color.ByARGB(255,115,200,26));
srf2=Display.ByGeometryColor(sub6.Patch(),Color.ByARGB(255,105,100,26));
srf11=Flatten(List.TakeItems({srf1,srf2},n));
sub21=Flatten(List.TakeItems({sub3,sub6},n));