Technical Penitence

I have a rule about not going to see any films which have won (or may win) at Venice or Cannes, I violated that rule and, to my regret, saw Le Meraviglie.

So I should have remembered that violating my own rules usually ends in tears.

STL is the format most accepted by 3d printers. I wanted to create a medal or coin shaped object in STL. The problem with STL is that, apart from the huge file size, the mesh of triangles must be connected together in a proscribed way. Basically a triangle corner must not finish on a triangle edge:


The triangles C B and E are illegal in STL as they are shown above because the corners of C and B touch the edge (not the corner) of E. 3D printers would spit any object like that out. That is just one of the problems of making STL files.

Another problem, from my point of view, is that I have to modulate the triangle heights to follow the dark and light of the user's photo for my program PhotoToMesh. So how to I make a regular array of triangles in the shape of a disk which can be modulated like that?

My first simple idea was simply radial lines and concentric polygons:




And here I made my mistake. I should have followed my usual rule of programming: "If there is a simple solution, use that. Only if the simple solution gives you problems go for a complex one".

I looked at the above image and thought. "Oooooh! I don't like those tightly packed triangles in the center of the disk. Bound to cause me problems! What can I do to make the tesselation (division into triangles) more even?"

After much thought I came up with a solution of having a central square grid surrounded by four chords.


This would mean that in the most important part of the medal or coin the bas relief of the users' photo would have a pleasant, even, regular grid.

I did a few experiments by hand to see how the chord mesh triangles would be distributed, and they looked pretty even, compared with the central mess in the first image:




The indexing of the points was a bit of a nightmare, especially the external circumference ones, which I needed to know if I was to build a cylinder from the face.

But when I saw how beautiful the final whole face was...


...I sort of fell in love with it. And I followed my love into the dark jungle...

To get this buggar to work in 3D and collaborate with other meshes it needed to talk too was a nightmare. I sort of managed it, but when I tested it with a large amount of points what did I see?



Not only was the programming difficult but I was getting just as much a mess of triangles at the top of the chord as I'd been trying to avoid in the center by rejecting my original idea! And what is worse the mess with my new improved solution was repeated four times! Look: North South East and West:




Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted Expletive Deleted!

Had I followed my own rule about keeping things simple I'd have finished in a quarter of the time and had a much easier program to debug.

Comments

  1. I now believe that the radial mess is worse than the edge effect mess. Now, where the hell did I put that backup...?

    ReplyDelete

Post a Comment

Popular posts from this blog

3D printers – about time I got one eh?

How I don't learn from experience