<p>I can't leave a comment, because I don't have enough reputation points.</p>
<p>Do you know how to represent your objects using an <em>implicit</em> function like f(x, y, z)? If so, then you can use Marching Cubes or Dual Contouring, or some similar algorithm to convert that field into a triangle mesh.</p>
<p>As you can see in the source, the tori are multiplied together, and a non-zero isovalue is used.</p>
<p>The final code is at: <a href="https://github.com/sjhalayka/k-genus_torus" rel="nofollow noreferrer">https://github.com/sjhalayka/k-genus_torus</a></p>
<p><a href="https://i.sstatic.net/r38ND.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/r38ND.png" alt="genus 5 tori" /></a></p>

CC BY-SA 4.0
2023-11-04T17:42:54.630Z
I assume you meant implicit function, e.g. $f(x,y,z) = 0$, and not parametric function, e.g. $(x(u,v), y(u,v), z(u,v))$. But yes, I could theoretically use an implicit function where I smooth merge two tori sdfs.
lightxbulb
CC BY-SA 4.0
2023-11-04T19:11:32.817Z
My bad, I appreciate the correction. I changed the answer.
shawn_halayka
CC BY-SA 4.0
2023-11-12T00:13:26.910Z
@lightxbulb I altered the answer.
shawn_halayka
CC BY-SA 4.0
2023-11-04T16:56:47.457Z
2023-11-11T03:46:42.153Z
2023-11-11T03:46:42.153Z
shawn_halayka
<p>I am looking for code or pseudo-code for the generation of genus <span class="math-container">$k$</span> tori triangle meshes. I want to get something like in the image <a href="https://en.m.wikipedia.org/wiki/Connected_sum" rel="nofollow noreferrer">here</a>. Book/paper references, code, github links, etc. are all welcome.</p>

<mesh><triangulation><procedural-generation>
Procedural generation of genus $k$ tori triangle meshes
lightxbulb
# Procedural generation of genus $k$ tori triangle meshes

(Asked by: username_0 on 2023-11-04)

I am looking for code or pseudo-code for the generation of genus $k$ tori triangle meshes. I want to get something like in the image [here](https://en.m.wikipedia.org/wiki/Connected_sum). Book/paper references, code, github links, etc. are all welcome.

**Tags:** mesh, triangulation, procedural-generation


---

## 1 answers

### Answer by username_1 on 2023-11-04. Score: 1 | Accepted answer

I can't leave a comment, because I don't have enough reputation points.

Do you know how to represent your objects using an *implicit* function like f(x, y, z)? If so, then you can use Marching Cubes or Dual Contouring, or some similar algorithm to convert that field into a triangle mesh.

As you can see in the source, the tori are multiplied together, and a non-zero isovalue is used.

The final code is at: <https://github.com/sjhalayka/k-genus_torus>

[![genus 5 tori](https://i.sstatic.net/r38ND.png)](https://i.sstatic.net/r38ND.png)

> **Comments:**
> **username_0**: I assume you meant implicit function, e.g. $f(x,y,z) = 0$, and not parametric function, e.g. $(x(u,v), y(u,v), z(u,v))$. But yes, I could theoretically use an implicit function where I smooth merge two tori sdfs.  
> **username_1**: My bad, I appreciate the correction. I changed the answer.  
> **username_1**: @username_0 I altered the answer.  

---

