1
\$\begingroup\$

I can easily get a list of coordinates of all the vertices—the Wikipedia page has formulae and this page has a list of them, but that doesn't tell me which ones are part of which face.

What I'd like is to create an array of 32 faces, and for each one have:

  • The 3-coordinate of the center of the face
  • The rotation of the face about the center point
  • Whether it's a pentagon or a hexagon

How can I generate that data?

\$\endgroup\$
2
  • 3
    \$\begingroup\$ To be honest I usually just hard-code the topology at the first level — a paper model I can draw on helps me keep track of my numbering — and then only try to get clever about generating topology when aubdividing/tessellating from that hard-coded base. \$\endgroup\$
    – DMGregory
    May 19, 2019 at 8:07
  • \$\begingroup\$ I have to generate the data before I can hard code it... \$\endgroup\$
    – Isvara
    May 20, 2019 at 22:28

1 Answer 1

2
\$\begingroup\$

I'd suggest you use Blender. It's easy to get the information you want for any geometric object you create, using python scripts. It's free, easy to use and you can get extensive support online.

1) download Blender here: https://www.blender.org/download/ (it's free)

2) Check this question, first answer, to create easily a truncated icosahedron https://blender.stackexchange.com/questions/31727/truncated-icosahedron

3) Go to "Objects mode" and select your geometry (right mouse button).

4) Open the python console by pressing Shift-F4. Copy and paste this script:

import bpy, bmesh
obj = bpy.context.active_object
verts = [vert.co.to_tuple() for vert in obj.data.vertices]
faces = [ [ vertex for vertex in face.vertices ] for face in obj.data.polygons]

Now verts is a list of the coordinates of all the vertices, and faces is a list of all the faces. Each face is a list of indices referencing to the verts list. You can inspect them using print verts and print faces. I would suggest you save them to a file, using numpy for example.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks. That looks useful. I think what I ultimately need is to calculate a transformation from the origin to a face. I can get the translation by averaging the vertices of the face. Can I get the rotation also? \$\endgroup\$
    – Isvara
    May 20, 2019 at 22:32
  • \$\begingroup\$ @DanEllis hint: if the polyhedron is centered at the origin, the face center IS the face normal. \$\endgroup\$
    – DMGregory
    May 21, 2019 at 1:09
  • \$\begingroup\$ @Turms Okay, so each polygon has a center attribute, which I can use as the translation. But what about the rotation? There's a normal attribute, so can I use that somehow? Or will that only give me the rotation of the plane the face is on, and not include the actual orientation of the pentagon or hexagon? \$\endgroup\$
    – Isvara
    May 21, 2019 at 5:18
  • \$\begingroup\$ The orientation of the plane (given by the normal) of the pentagon is the same as the orientation of the pentagon. Or do you mean the rotation of the pentagon around its normal axis? \$\endgroup\$
    – Turms
    May 21, 2019 at 6:43
  • \$\begingroup\$ @Turms Right, exactly. It needs to include the rotation around the normal axis. \$\endgroup\$
    – Isvara
    May 21, 2019 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .