# Translate to center of mass

**URL:** <https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207>\
**Category:** Suggestions\
**Created:** [October 31, 2025, 12:57am UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207 "2025-10-31T00:57:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 12:57am UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/1 "2025-10-31T00:57:51Z")

</div>

There is a 2015 post about this but no one answered. I know you can generate a “Xx” point at the center of mass but is there a way to translate the molecule to it?

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 1:00am UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/2 "2025-10-31T01:00:43Z")

</div>

Relatedly, now I remember there was something strange happening with the calculation of the center of mass…

# D[efining centers of mass wrt given atoms](https://discuss.avogadro.cc/t/defining-centers-of-mass-wrt-given-atoms/6766)

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2025, 3:02am UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/3 "2025-10-31T03:02:43Z")

</div>

I’m pretty sure that’s been [fixed](https://github.com/OpenChemistry/avogadrolibs/pull/1891).

Use the align tool. Click on the centroid and click align. It will translate everything so that the selected atom is at the origin:

 ![AlignCentroid](https://discuss.avogadro.cc/uploads/default/original/2X/d/d7ee9a56e51f06c7404d69ed466af8e92683bccb.png)

If you only click on one atom, the align tool translates that to the origin. If you click on two atoms, it will align the second atom with the specified axis.

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 4:14pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/4 "2025-10-31T16:14:54Z")

</div>

My 1.102.1 still places the CM outside of the internuclear axis for the NO example I was using before.

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/c/cc43c688713559e9faf15e810ae7bc564fc2bcf4.jpeg)

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2025, 4:59pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/5 "2025-10-31T16:59:47Z")

</div>

I’m scratching my head. I can’t reproduce that at all.

I just entered your exact system, (i.e., the N and O atoms at those positions) clicked “Add Center of Mass” and got

 ![CenterOfMass](https://discuss.avogadro.cc/uploads/default/original/2X/5/5e6076d8f701c666d9200e22476cdb1e17888423.png)

I’m also looking at the code, and I don’t see any way you’d get an x-component:

> <https://github.com/OpenChemistry/avogadrolibs/blob/58b37da73d9613d5cba0bffe42263e008d135ebd/avogadro/qtplugins/centroid/centroid.cpp#L88>

I’ve been trying a few orientations and I can’t get that to happen.

Can you send me the NO example without the center-of-mass added so I can check it? Maybe there’s something I’m missing.

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 5:24pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/6 "2025-10-31T17:24:30Z")

</div>

You mean an output file? I have none - I build the molecule from the Cartesian editor. So something interesting happen - sometimes it works correctly and some time it doest not. Here is a .gif of when it worked.

![Working](https://discuss.avogadro.cc/uploads/default/original/2X/c/c5594f09708f20375b487b8892c3f2455133c5d4.gif)

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 5:29pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/7 "2025-10-31T17:29:09Z")

</div>

And here is an example of when it is not. One difference I can see is that on the “working case” I entered the coordinates as:

`N 0.0 0.5685 0.0`

` O 0.0 -0.5685 0.0`

but on the not-working case I entered them as

`N 0.0 0.5685 0.0`  
`O 0.0 -0.5685 0.0`

![Not working](https://discuss.avogadro.cc/uploads/default/original/2X/1/1a7fb433795ea7e93ef9640406a086d1cf8fec9a.gif)

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 7:07pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/8 "2025-10-31T19:07:26Z")

</div>

Here’s an .xyz file for a moleculer that I manually translated to the CoM. When I open it and calculate the CoM with Avogadro I get 0 on the y and z coordinate but I get the same 0.003332 as NO) on the x coordinate.

 ![Screenshot 2025-10-31 at 1.03.53 PM](https://discuss.avogadro.cc/uploads/default/original/2X/3/34831b67d719c0a74bd8f18b1206cca2efd911a8.jpeg)

[after\_average.xyz](https://discuss.avogadro.cc/uploads/short-url/ArfsemYoT6bOYhKLL3zsI0388hF.xyz) (1.1 KB)

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2025, 7:18pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/9 "2025-10-31T19:18:45Z")

</div>

This feels like some sort of weird compiler optimization bug (e.g., numeric noise). For example, I absolutely cannot reproduce it on my M4 MacBook, but my M1 desktop shows it _sometimes_ but not all the time.

As far as the underlying code, there’s no difference between the two examples you gave, or N as first atom and O as second or vice-versa.

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 7:50pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/10 "2025-10-31T19:50:39Z")

</div>

Yikes… I suppose for now I’ll not use this functionality. It’s easy to see for NO but for more complex systems I wouldn’t be able to tell if the CoM calculated by Avogadro is “a little off”. This is relevant to me because I’m working on a project involving external electric fields and I need my molecules placed and oriented in very specific ways.

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2025, 7:54pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/11 "2025-10-31T19:54:33Z")

</div>

Give me a bit - I’m putting in a new Mac build that at least in the times I’ve checked it doesn’t have problems.

As you might imagine, we do plenty of calculations in electric fields, although we often script the preparation in Python.

It’s one reason for the align tool.

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2025, 9:10pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/12 "2025-10-31T21:10:46Z")

</div>

Okay, give this Mac ARM build a try, or wait ~20 minutes for the continuous build to update:  
[https://github.com/OpenChemistry/avogadrolibs/releases/download/continuous/Avogadro2-continuous-arm64.dmg](https://github.com/OpenChemistry/avogadrolibs/releases/download/continuous/Avogadro2-continuous-arm64.dmg)

---

<div class="post-metadata">

**Author:** ![Juanes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/juanes/32/2256_2.png) [@Juanes](https://discuss.avogadro.cc/u/Juanes)\
**Post date:** [October 31, 2025, 10:48pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/13 "2025-10-31T22:48:41Z")

</div>

Ok I think it works! That same .xyz file does not show the strange 0.003332 for the CoM in the x coordinate.

 ![image](https://discuss.avogadro.cc/uploads/default/original/2X/7/703d8080ade6d2e7b384d4e47209100e6a7d941a.jpeg)

One question that remains for me is: what is the argument to use the average isotope masses for the CoM calculation vs. those of the most common isotope?

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2025, 11:40pm UTC](https://discuss.avogadro.cc/t/translate-to-center-of-mass/7207/14 "2025-10-31T23:40:58Z")

</div>

> [@Juanes](#):
>
> One question that remains for me is: what is the argument to use the average isotope masses for the CoM calculation vs. those of the most common isotope?

At the moment, we don’t have isotopes so it’s going off the average isotope masses. Most common isotopes / specific isotopes will go in soon. For that, there will probably be a command to assign isotopes with the default being the most common.
