# Adding center of mass properties to vtkMassProperties

**URL:** https://discourse.vtk.org/t/adding-center-of-mass-properties-to-vtkmassproperties/653
**Category:** Development
**Tags:** proposal
**Created:** [April 1, 2019, 8:36am UTC](https://discourse.vtk.org/t/adding-center-of-mass-properties-to-vtkmassproperties/653 "2019-04-01T08:36:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rdbrn](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rdbrn/32/5627_2.png) [@rdbrn](https://discourse.vtk.org/u/rdbrn)
#### Post date: [April 1, 2019, 8:36am UTC](https://discourse.vtk.org/t/adding-center-of-mass-properties-to-vtkmassproperties/653/1 "2019-04-01T08:36:52Z")

</div>

I propose to add VolumeCenterX, VolumeCenterY and VolumeCenterZ to vtkMassProperties.

These properties are easy to calculate as follows:  
for each triangle:  
create a tetrahedron for the three vertices of this triangle plus the origin as fourth vertex  
calculate volume and center of this tetrahedron.

the overall center of mass is then the weighted average of all these centers.

I can add the code to vtkMassProperties.h and vtkMassProperties.cxx

But besides that, what other places do I need to make changes/additions? Test cases, documentation, exposure to python, etc?

---

<div class="post-metadata">

### Author: ![normanius](https://discourse.vtk.org/user_avatar/discourse.vtk.org/normanius/32/611_2.png) [@normanius](https://discourse.vtk.org/u/normanius)
#### Post date: [May 5, 2020, 2:28pm UTC](https://discourse.vtk.org/t/adding-center-of-mass-properties-to-vtkmassproperties/653/2 "2020-05-05T14:28:27Z")

</div>

I support this request. Besides volume-based center of mass, please add also surface-based center of mass. And if we are at it, support `UseScalarsAsWeight` when iterating over the cells, which is required to compute volume and area.

See [this topic](https://discourse.vtk.org/t/how-to-compute-surface-and-volume-based-center-of-masses-for-3d-geometries/3215) where I was asking for a similar feature.
