# Calculate the centroid of a simplex surface?

**URL:** https://discourse.itk.org/t/calculate-the-centroid-of-a-simplex-surface/2096
**Category:** Uncategorized
**Created:** [July 26, 2019, 5:28pm UTC](https://discourse.itk.org/t/calculate-the-centroid-of-a-simplex-surface/2096 "2019-07-26T17:28:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![srbn.ghosh89](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@srbn.ghosh89](https://discourse.itk.org/u/srbn.ghosh89)
#### Post date: [July 26, 2019, 5:28pm UTC](https://discourse.itk.org/t/calculate-the-centroid-of-a-simplex-surface/2096/1 "2019-07-26T17:28:33Z")

</div>

I have simplex surface and I need to calculate centroid of different parts of the simplex? The edges are not similar in every side. Screenshots attached.

![17](https://discourse.itk.org/uploads/default/original/1X/cce0e233610d6f38312aed78d3c07c7698d05eff.png)

 ![18](https://discourse.itk.org/uploads/default/original/1X/26b2ff7c50ad446974849051bd77f8d34b5fe3f2.png)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [July 26, 2019, 8:36pm UTC](https://discourse.itk.org/t/calculate-the-centroid-of-a-simplex-surface/2096/2 "2019-07-26T20:36:25Z")

</div>

For a closed volume part, one way to do it is to:

1. pick a random point as guessed center
2. calculate volume of each tetrahedron formed by the point and the triangles of the part
3. keep a sum of the multiples of small tetrahedons’ volume and center
4. divide the sum by the total volume

Here is an [example code](https://github.com/dzenanz/SpineSource/blob/334d6893422f5c80277725c8d5c2938d8698111e/SpineAI/vertebra.cpp#L478-L504).

---

<div class="post-metadata">

### Author: ![srbn.ghosh89](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/3ec8ea/32.png) [@srbn.ghosh89](https://discourse.itk.org/u/srbn.ghosh89)
#### Post date: [July 26, 2019, 8:49pm UTC](https://discourse.itk.org/t/calculate-the-centroid-of-a-simplex-surface/2096/3 "2019-07-26T20:49:20Z")

</div>

This is simplex mesh. If I would say, may be all of the simplex cells will not have the same number of edges like 6 or 8. Still is it gonna work with your steps?

 ![19](https://discourse.itk.org/uploads/default/original/1X/573b90d10d215189857a6ee233ee3fa2bb9be7ba.png)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [July 26, 2019, 8:55pm UTC](https://discourse.itk.org/t/calculate-the-centroid-of-a-simplex-surface/2096/4 "2019-07-26T20:55:53Z")

</div>

Calculating volume of a single cell formed by a single face and arbitrary center will be more complicated than a simple vector cross product, but it should still work.
