It's calculated differently because without it the rings get laid out on
top of each other. Example case, you can reverse this commit:
https://github.com/cdk/cdk/commit/6533533a95b5e9ca0d55d0d37ab5f048a25e88f7#diff-da65f1759b150e9510a643e017112b3f
And see how it lays out the following.
C1CO[Fe]234(O1)OCCO2.C(CO3)O4
[image: image.png]
The old code would generate this:
[image: image.png]
because the bond vector was pointing towards the centre of the ring.
John
On Wed, 20 Nov 2019 at 16:36, Christoph Steinbeck <
christoph.steinb...@uni-jena.de> wrote:
> This is very old code and it seem that others changed it (to the better
> :)) since I wrote it long time ago.
> If I understand you correctly, there is actually no bug, just an apparent
> inconsistency that you are reporting.
> The simplest thing would be for you to remove the case distinction and see
> what happens.
> Maybe that reveals the reason for the distinction.
>
> I’d love to dig into this but I lack the time for such fun these days
> Very sad. :D
>
> All the best,
>
> Chris
>
> —
> Prof. Dr. Christoph Steinbeck
> Analytical Chemistry - Cheminformatics and Chemometrics
> Friedrich-Schiller-University Jena, Germany
> Phone Secretariat: +49-3641-948171
> http://cheminf.uni-jena.de
> http://orcid.org/-0001-6966-0814
>
> What is man but that lofty spirit - that sense of enterprise.
> ... Kirk, "I, Mudd," stardate 4513.3..
>
> > On 18. Nov 2019, at 16:24, 努力努力 <843982...@qq.com> wrote:
> >
> > Thanks for your reply.
> > I want to implement a JChemPaint in C#. In fact, I used a CDK port,
> named NCDK which is C# impementation implementation of the Chemistry
> Development Kit. https://github.com/kazuyaujihara/NCDK.
> > But I have got some bugs. I want to read the source code of CDK and fix
> it.
> > The bug is like this:
> > When we addRing, we need to calculate the position of the virtual ring.
> From the code , I understand that the position of the new ring need to be
> calculated by some variables, include the new ring center, startAngle,
> addAngle, radius.
> > The code in function "placeSpiroRing" is
> > atomPlacer.populatePolygonCorners(atomsToDraw, ringCenter, startAngle,
> addAngle, radius);
> > The variable ringCenter is dependent on the variable ringCenterVector
> which is a vector pointing the the center of the new ring.
> >
> > For example, when I want to add a triangle to a shared atom, It
> satisfies numplace==2.It seems that the sharedAtom' s position will be
> changed.
> > The code in function "placeSpiroRing" is
> > if (numPlaced == 2) {
> > // nudge the shared atom such that bond lengths will be
> > // equal
> > startAtom.getPoint2d().add(ringCenterVector);
> > sharedAtomsCenter.add(ringCenterVector);
> > }
> > And when degree == 4 and degree != 4, ringCenterVector is differently
> recalculate. Why?
> > The code in function "placeSpiroRing" is
> > if (degree == 4) {
> > ringCenterVector.normalize();
> > ringCenterVector.scale(radius);
> > } else {
> > // spread things out a little for multiple spiro centres
> > ringCenterVector.normalize();
> > ringCenterVector.scale(2*radius);
> > }
> > I'm confused. Or I understand it wrong.
> >
> > Thank you for taking your time to read this letter again.
> >
> > -- 原始邮件 --
> > 发件人: "Christoph Steinbeck";
> > 发送时间: 2019年11月18日(星期一) 晚上6:55
> > 收件人: "努力努力"<843982...@qq.com>;
> > 抄送: "cdk-user";
> > 主题: Re: [Cdk-user] Questions about the function "Addring"
> >
> > Can you comment on what you try to achieve?
> > The method that you are referring to is a quite specialised method for
> structure diagram layout.
> > Are you trying to create 2D drawings of some molecule or fragment, or
> maybe something else?
> >
> > Kind regards, Chris
> >
> > —
> > Prof. Dr. Christoph Steinbeck
> > Analytical Chemistry - Cheminformatics and Chemometrics
> > Friedrich-Schiller-University Jena, Germany
> > Phone Secretariat: +49-3641-948171
> > http://cheminf.uni-jena.de
> > http://orcid.org/-0001-6966-0814
> >
> > What is man but that lofty spirit - that sense of enterprise.
> > ... Kirk, "I, Mudd," stardate 4513.3..
> >
> > > On 18. Nov 2019, at 11:32, 努力努力 <843982...@qq.com> wrote:
> > >
> > > Dear all,
> > > i want to understand how to add rings in the atom.In the function
> "Addring",I find the code "ringPlacer.PlaceSpiroRing" and then jump to the
> function "placeSpiroRing".And I have some problems about this function.Why
> do we have special treatment when degree==4 and numplace==2? In my
> understanding, "degree" is the number of bonds connected to sharedAtoms,
> and numPlaced is the number of other Atoms ring except sharedAtoms.
> > > Looking forward to your reply. Thank you!
> > >
> > > The source code from CDK is here:
> > > public void placeSpiroRing(IRing ring, IAtomContainer sharedAtoms,
> Point2d