# Center of mass , (center of data)

**URL:** https://discourse.paraview.org/t/center-of-mass-center-of-data/1273
**Category:** ParaView Support
**Created:** [February 11, 2019, 4:44pm UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273 "2019-02-11T16:44:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![drudox00](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@drudox00](https://discourse.paraview.org/u/drudox00)
#### Post date: [February 11, 2019, 4:44pm UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/1 "2019-02-11T16:44:00Z")

</div>

Hi all ,  
I have a set of 3d points that rapresent atoms in a macro molecule , the atoms mass is the same for each atoms in the molecule, there is a way in paraview to found the center of a certain number of point that rapresent my data in a VTK polydata file ? there is no information about mass , I need just to find out the geometric center of the set of 3d points  
How can I do that ?

---

<div class="post-metadata">

### Author: ![drudox00](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@drudox00](https://discourse.paraview.org/u/drudox00)
#### Post date: [February 12, 2019, 7:39am UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/2 "2019-02-12T07:39:40Z")

</div>

there is not a tools … like filter to compute that points ?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 12, 2019, 8:57am UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/3 "2019-02-12T08:57:10Z")

</div>

What about `CellCenters` filter?

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [February 12, 2019, 6:48pm UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/4 "2019-02-12T18:48:33Z")

</div>

@mwestphal I believe the user is asking for the center point of the dataset, not the center point of individual cells.

I believe the filter to do this doesn’t exist. However, you can easily build one. The tools for this are found in the tips and tricks post here: [Pointing the camera at the center of a dataset using Python](https://discourse.paraview.org/t/pointing-the-camera-at-the-center-of-a-dataset-using-python/1257). What you are asking for is the center of the bounds.

---

<div class="post-metadata">

### Author: ![drudox00](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@drudox00](https://discourse.paraview.org/u/drudox00)
#### Post date: [February 13, 2019, 7:12am UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/5 "2019-02-13T07:12:19Z")

</div>

yes I need to find the center of the points not the center of cell ! I need to know the coordinate of the center not just to center the camera is it possible ?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 13, 2019, 9:06am UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/6 "2019-02-13T09:06:30Z")

</div>

You will need to implement that as a Programmable Filter.  
[https://www.paraview.org/Wiki/Python\_Programmable\_Filter](https://www.paraview.org/Wiki/Python_Programmable_Filter)

---

<div class="post-metadata">

### Author: ![drudox00](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@drudox00](https://discourse.paraview.org/u/drudox00)
#### Post date: [February 13, 2019, 10:25am UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/7 "2019-02-13T10:25:55Z")

</div>

I’m have not idea of how to implement … may give me an help ?

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [February 13, 2019, 12:31pm UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/8 "2019-02-13T12:31:28Z")

</div>

The following steps should get you the center of mass (being the average of a set of equally weighted points) without having to write a programmable filter. (It will give you the coordinates but not draw them in the 3D view.)

1. Add the `Calculator` filter.  
1.a. Set the `Result Array Name` to `position`  
1.b. Set the expression (the text box right above the calculator buttons) to `coords`.  
1.c Hit `Apply`. (This will create a field named `position` containing the coordinates of each point.)
2. Run the `Descriptive Statistics` filter. `Apply`.

Once run, the `Descriptive Statistics` filter will open up a spreadsheet view showing statistics like mean, min, max, etc. The mean for `position_0` (X), `position_1` (Y), and `position_2` (Z) should give the center of gravity of your molecule. (That is, if I understand your problem correctly.)

---

<div class="post-metadata">

### Author: ![Gening\_Dong](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gening_dong/32/10295_2.png) [@Gening\_Dong](https://discourse.paraview.org/u/Gening_Dong)
#### Post date: [April 25, 2023, 8:27pm UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/9 "2023-04-25T20:27:15Z")

</div>

Hi,

Thank you for this solution, it works well! However, I have a follow up question. So I have two datasets (two different geometries) with different centroids. Can I reposition one so both geometries can share the same centroid? Thanks in advance!

Gening

---

<div class="post-metadata">

### Author: ![otaolafr](https://discourse.paraview.org/user_avatar/discourse.paraview.org/otaolafr/32/3595_2.png) [@otaolafr](https://discourse.paraview.org/u/otaolafr)
#### Post date: [January 10, 2025, 2:36pm UTC](https://discourse.paraview.org/t/center-of-mass-center-of-data/1273/10 "2025-01-10T14:36:22Z")

</div>

Hello Kenneth,  
small question,  
I would like to recover the values (position\_i) from python.  
for this I was using:  
data=dsa.WrapDataObject(servermanager.Fetch(descriptiveStatisticsFilter))  
but from there I am blocked, as descriptiveStatisticsFilter has ‘Row data’ and I am not being able to find how to acces this from the data object.  
would appreciate some insight on this.  
thanks
