Skip to content
Advertisement

Python: Enumeration based on an enumerated list

I have several vertexes that compose two triangles.

Vertexes:

JavaScript

Triangles:

JavaScript

Now I need to export this data to a .txt file, to have the following output composed by two different parts:

JavaScript

The first part was easy, as I only needed to enumerate each vertex based on the aforementioned list.

JavaScript

The problem is with the second part, as I need to enumerate each triangle (first column) and then assign the values previously given in part 1 to each vertex that compose the triangle.

e.g. triangle ABC is composed by vertexes 1, 2 and 3; triangle ACD is composed by vertexes 1,3 and 4, so the output (previously presented) should be:

JavaScript

I would appreciate any help you could give me on this. Thanks so much.

Advertisement

Answer

It looks like you would do something very similar.

This would get the vertices:

JavaScript

This is the output:

JavaScript

or more generally make a list of triagles and solve in the same way like this:

JavaScript

which gives this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement