# Avogadro is handling of coordinates ok?

**URL:** <https://discuss.avogadro.cc/t/avogadro-is-handling-of-coordinates-ok/1711>\
**Category:** Development\
**Created:** [January 26, 2010, 10:45am UTC](https://discuss.avogadro.cc/t/avogadro-is-handling-of-coordinates-ok/1711 "2010-01-26T10:45:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![B\_W\_H\_van\_Beest](https://discuss.avogadro.cc/letter_avatar_proxy/v4/letter/b/f08c70/32.png) [@B\_W\_H\_van\_Beest](https://discuss.avogadro.cc/u/B_W_H_van_Beest)\
**Post date:** [January 26, 2010, 10:45am UTC](https://discuss.avogadro.cc/t/avogadro-is-handling-of-coordinates-ok/1711/1 "2010-01-26T10:45:54Z")

</div>

Hi,

I encounter unexpected behaviour of Avogadro when working on an  
extension plugin. I observe an inconsistency in how Avogadro  
handles atomic coordinates depending on the origin of the data.  
This is what I do in my plugin:

================================

1. "Download step: I copy the atomic positions from Avogadro to the plugin.  
(By first creating an instance OpenBabel::OBMol from an  
Avogadro::Molecule, and then using the access functions of  
OpenBabel::OBMol and OpenBabel::OBAtom.)

2. In the plugin, I modify the coordinates of the atoms (MD, minimisation)

3. Upload step:  
I copy back the -modified- coordinates of the molecule into Avogadro.  
(By using the Avogadro::Molecule access function setAtomPos:

TO check if things are working as expected I output the atomic  
coordinates in the plugin to the screen, where I compare them to the  
coordinates as displayed in the build-\>Cartesian Editor. It turns out  
that the download step always copies the coordinates correctly from the  
Avogadro host to the plugin. The upload step, howver, fails in certain  
situations.

Here is my problem: depending on how I have created the molecule (in  
Avogadro, the procudure above succeeds or fails.

- When I have obtained the molecule in Avogadro by loading it from a  
file (in my case, a Sybyl mol2 file) there is no problem.  
the coordinates in the plugin are always identical to the ones in  
Avogadro via the above mechanism.

- When I create a molecule interactively, the above procedure shows in  
the upload step large differences.  
There is a subtlety here which may point to the a clue:

Is there someone who can explain me what cold be going on here? Is there  
a difference (in Avogadro) between a molecule that is created  
interactively and one that is loaded from file?

Kind Regards,  
Bertwim

---

<div class="post-metadata">

**Author:** ![allison.vacanti](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/allison.vacanti/32/112_2.png) [@allison.vacanti](https://discuss.avogadro.cc/u/allison.vacanti)\
**Post date:** [January 26, 2010, 1:11pm UTC](https://discuss.avogadro.cc/t/avogadro-is-handling-of-coordinates-ok/1711/2 "2010-01-26T13:11:40Z")

</div>

On Tue, Jan 26, 2010 at 5:45 AM, B.W.H. van Beest [bwvb@xs4all.nl](mailto:bwvb@xs4all.nl) wrote:

> Hi,
> 
> I encounter unexpected behaviour of Avogadro when working on an  
> extension plugin. I observe an inconsistency in how Avogadro  
> handles atomic coordinates depending on the origin of the data.  
> This is what I do in my plugin:

What is Avogadro doing that is wrong? Is it moving the wrong atoms to  
correct coordinates, eg A should be at (0,0,0) and B at (1,1,1), but A  
is a (1,1,1) and B is at (0,0,0)? Or is it moving A to (10,2,37) and B  
to (-12,14,-6)? WIthout knowing what Avo is doing wrong it is hard to  
say what’s happening.

Dave

---

<div class="post-metadata">

**Author:** ![B\_W\_H\_van\_Beest](https://discuss.avogadro.cc/letter_avatar_proxy/v4/letter/b/f08c70/32.png) [@B\_W\_H\_van\_Beest](https://discuss.avogadro.cc/u/B_W_H_van_Beest)\
**Post date:** [February 5, 2010, 7:48pm UTC](https://discuss.avogadro.cc/t/avogadro-is-handling-of-coordinates-ok/1711/3 "2010-02-05T19:48:06Z")

</div>

Yes, I realise it is hard to imagine

Molecule read from file: Correct behaviour.

1. Atom A (x,y,z) is copied to extension, where is has the same  
coordinates (x,y,z)
2. In the extension, atom A changes its position, e.g. due to a MD time  
step or minimisation: (x,y,z) → (x’, y’, z’)
3. Atom coordinates are copied back to Avogadro: The _same_ (x’,y’z’)  
are now seen in the cartesian editor.

Molecule built interactively: Wrong behaviour:  
(e.g. C10H22 is “clicked together”, by clicking on the canvas to and  
connecting the fragments. Avogadro automatically adds the hydrogens.)

1. As above: coordinates are copied ok.
2. As above, (x,y,z) → (x’, y’, z’) in the extension.
3. Atom coordinates are copied back from extension to Avogadro.  
However, I now see  
different cooordinates, say (x", y", z") in the cartesion editor.  
There is no swapping of atoms, just different coordinates.

NOTE: on further inspection it seems that the atoms in the fragment  
that is created first are ok! The others are different.  
(some a few percent, others are way-off.  
Perhaps this last NOTE offers a clou?

Regards,  
Bertwim

David Lonie wrote:

> On Tue, Jan 26, 2010 at 5:45 AM, B.W.H. van Beest [bwvb@xs4all.nl](mailto:bwvb@xs4all.nl) wrote:
> 
> > Hi,
> > 
> > I encounter unexpected behaviour of Avogadro when working on an  
> > extension plugin. I observe an inconsistency in how Avogadro  
> > handles atomic coordinates depending on the origin of the data.  
> > This is what I do in my plugin:
> 
> What is Avogadro doing that is wrong? Is it moving the wrong atoms to  
> correct coordinates, eg A should be at (0,0,0) and B at (1,1,1), but A  
> is a (1,1,1) and B is at (0,0,0)? Or is it moving A to (10,2,37) and B  
> to (-12,14,-6)? WIthout knowing what Avo is doing wrong it is hard to  
> say what’s happening.
> 
> Dave
