# Pattern //Length of smallest side
side = 1;
//Number of modules (X)
nx = 8;
//Number of modules (Y)
ny = 8;
//The module is a square with an inscribed regular Octagon and another smaller Octagon within
//The dimension of the square side is equal to twice the Apothem of the Larger Octagon
//The length of the large Octagon side is twice the length of the smaller Octagon
//The Apothem of the larger Octagon is calculated
a = side/(2*Math.Tan(180/8));
//The circumradius of the large Octagon
r = a/(Math.Cos(180/8));
//Points for one module
//Corner Points of Bounding Square
pnt01 = Point.ByCoordinates({2*a,-2*a,-2*a,2*a},{2*a,2*a,-2*a,-2*a});
//Midpoints of large Octagon sides
pnt02 = (Point.Origin()).Translate(Vector.XAxis(),2*a).Rotate(Point.Origin(),Vector.ZAxis(),45..360..45);
//Corner Points of Large Octagon
pnt03 = (Point.Origin()).Translate(Vector.XAxis(),2*r).Rotate(Point.Origin(),Vector.ZAxis(),22.5..337.5..45);
//Corner Points of Small Octagon
pnt04 = (Point.Origin()).Translate(Vector.XAxis(),r).Rotate(Point.Origin(),Vector.ZAxis(),22.5..337.5..45);
//Square Corner Triangulation
tri11 = Transpose({List.TakeEveryNthItem(pnt03,2,1),List.TakeEveryNthItem(pnt02,2,1),pnt01});
tri12 = Transpose({List.TakeEveryNthItem(pnt02,2,1),pnt01,List.TakeEveryNthItem(pnt03,2,0)});
//Large Octagon Triangulation
tri13 = Transpose({pnt02,pnt03,pnt04});
tri14 = Transpose({List.ShiftIndices(pnt03,-1),List.ShiftIndices(pnt02,-1),List.ShiftIndices(pnt04,-1)});
tri15 = Transpose({pnt02,pnt04,List.ShiftIndices(pnt04,-1)});
tri16 = Transpose({List.ShiftIndices(pnt03,-1),List.ShiftIndices(pnt02,0),List.ShiftIndices(pnt04,-1)});
//Small Octagon Triangulation