Complete definition …

equilateralSubDivision.dyn (4.9 KB)

Just for the sake of having a little fun

here’s a less geometric / more arithmetic way to see it:

if you look at a 2n+1 dimension matrix :

XOXOXOX

OXOXOXO

OOXOXOO

OOOXOOO

the pattern of the regular subdivision of an equilateral triangle goes :

## 0 2 4 … 2n+1

## 1 3 5 … 2n

2 4 6 … 2n-1

.

.

.

n+1

here’s a way to describe it in design script:

subdiv matrix.dyn (4.5 KB)Thank you so much for taking the time to offer your ideas. I wish I could grant more than one solution. Hopefully others in the future facing this same question can find this threat. I think it will help a lot of people build.

I’m excited to try and run this code into my script this week. I’m concerned about transplanting it into my larger script. I’ll report back if I have any problems.

The matrix method unfortunately doesn’t appear to orient to the surface I’m hoping to divide however when testing the other code before passing through my 20 surfaces I’m getting a strange offset on each subdivided triangle which is not in the example. I assume it has something to do with either Translate and “dirX” functions or the n2/n3/n4/n5 steps but when investigating against the original couldn’t see anything amiss. (Running the original dyn file on my system works as expected.)

Hi @PerfectArchCo

In order to get the matrix to adapt to the orientation of your surfaces, you can use coordinate systems. Here’s a code that will work wathever the orientation of your tirangle is :

```
//setting the coordinate system
p = s.PerimeterCurves();
l = p[0].Length;
h = l*Math.Sin(60);
pts = p.StartPoint;
csx = Vector.ByTwoPoints(pts[0],pts[1]);
csy = Vector.ByTwoPoints(pts[0],pts[2]);
cs = CoordinateSystem.ByOriginVectors(pts[0],csx,csy);
//creating matrix
n = subdivn*2+1;
rangex = 0..l..#n;
rangey = 0..h..#n;
matrix = Point.ByCartesianCoordinates(cs,rangex<2>,rangey<1>,0);
tripoints = List.TakeEveryNthItem(matrix,2,1);
//generating arithmetic suites
indx = 0..subdivn+1;
indy = n..subdivn+1;
suites = indx..indy..2;
//building triangles
pts2 = List.GetItemAtIndex(tripoints<1>,suites<1>);
c = List.Count(pts2<1>);
pts3 = List.Clean(List.GetItemAtIndex(pts2<1>,((0..c-1)..(1..c-1))<1>));
pts4 = List.DropItems(pts2,1);
corners = List.AddItemToFront(pts4<1><2>,pts3<1><2>);
Triangles = PolyCurve.ByPoints(corners,1);
//Using polysurface to split initial triangle
polysurf = PolySurface.ByJoinedSurfaces(Flatten(Triangles.Extrude(1)));
s.Split(polysurf);
```

You just neet to feed it your initial surface and the number of subdivisions. Hope this gets you where you want

subdiv matrix coordinate system.dyn (6.0 KB)

Check if the surface you are feeding in is equilateral.

Altered the file I’d provided above to accept an equilateral surface.

equilateralSubDivision.dyn (4.9 KB)

This is a very interesting problem. And I’ve seen that has very good solutions here.

I would also like to present another approach in order to be discussed.

I did this using another way taking the coordinates of the vertices of the main equilateral triangle, so that no matter their position in space.

It also returns the (x,y,z) of the vertex of each sub-triangle that can be used for panelling.

My ultimate goal was to build a parameterized geodesic dome. And I got. I used this Tom Davis

paper as a reference. geodesic dome.pdf (564.8 KB)

This triangulation was part of the process.

triangulacao-v07.dyn (30.9 KB)

Looking sharp @Vikram_Subbaiah.

Interestingly @Ricardo_Freitas I have that paper printed off and sitting within arms reach already. Unforuately that paper doesn’t cover how he subdivided the surface but then again, Dynamo is just so cool, who wouldn’t want to try it? I agree there’s lots of good approaches here and hopefully it will become a good resource for the forums.

Obtaining the points of the sub triangles is quite easily done by getting the vertices of the polygons/surfaces

Just adding to the resource

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));
```

Shows yes, read more carefully.

First you need an icosahedron and a co-centric sphere to him.

Then subdivided each face of the icosahedron with one of the methods shown here in order to obtain the vertices of each sub-triangle.

Then make the projection of each point on the surface of the sphere.

Now redo each sub-triangle with the projected points.

This is the procedure that Tom says in his paper.

It’s a brilliant idea right? I was very happy when I could do it.

The hardest part is actually making the sub-divisions.

Returning to your question about the surface being equilateral, it appears my surface is not equilateral. The watch node is displaying the magenta curve lengths. It appears only the top ones are offset and unequal as the lower ones are equal and tight to each other.

Would you suggest I go back and tweak the code which genorates the icosahedron? I don’t mind doing it. This stuff is just too much fun. I’m also going to experiment with some of the other impliminations to see what else I can learn.

Edit: it appears the maxtix approach fails for the same unequal triangle condition. Fascinating…

Does seem like the icosahedron code requires rectification

@Vikram_Subbaiah I replied in:

As the discussion to fix the icosahedron in my judgement is a seperate topic from Surface Subdivisions.

Thanks @Vikram_Subbaiah. Unfortunately when running in your code today I found a problem inputting the surface which I am attempting to resolve in another thread. As soon as I get the surfaces oriented correctly I will continue chipping away at implementing the corrections to my script. I will add though; this is absolutely fascinating stuff!

Awe. Sorry @Ricardo_Freitas . I did try your code – twice, same problem - but see now the context isn’t as clear as I thought it was. Please take no offense. VS’s is just whose I had up when I took the screen grab. The bigger picture is that your contribution to the thread is greatly appreciated, and even if it didn’t directly help me in this case it’s a great resource and for that I truly thank you. If we met in real life I would definitely raise a glass in graditude for your effort.

Displays yes @PerfectArchCo. It shows how to make the sub-division with a mathematical method from the coordinates of the vertices of the main triangle. It was exactly what I applied at Dynamo and it worked. I posted the DYN file in my first comment with the paper.

Below follows the transcript of the passage to which I refer

"**

## 7 Triangle Coordinates

**

If you know the 3D coordinates of the three vertices of a triangle in space and you wish to subdivide that triangle into n² smaller triangles and to determine the coordinates of the points of subdivision, the process is fairly simple.

Let’s use the example where n = 6 so the triangle is subdivided into 6² = 36 smaller triangles as in the following illustration:

If the 3D coordinates of the points at the top, bottom left and bottom right are A, B and C, respectively, then the coordinates of the interior points are given by the labels in the ﬁgure above, divided by 6. Thus the point labeled 2A + 3B + 1C will have coordinates A/3 + B/2 + C/6, et cetera. The coordinates are easily generated. Start from any vertex (say A, in which case the coordinates will be 6A + 0B + 0C – in other words, all A) and step along the lines to the desired vertex. Each time you step along a line in the direction from vertex Q toward vertex R, subtract 1 from the Q values and add 1 to the R value."

This is it.