Logo Search packages:      
Sourcecode: cdk version File versions  Download package

void org::openscience::cdk::modeling::builder3d::ModelBuilder3D::layoutRingSystem ( Point3d  originalCoord,
IAtom  placedRingAtom,
IRingSet  ringSet,
Point3d  centerPlacedMolecule,
IAtom  atomB,
AtomPlacer3D  ap3d 
) [inline, private]

Layout the ring system, rotate and translate the template.

Parameters:
originalCoordcoordinates of the placedRingAtom from the template
placedRingAtomplacedRingAtom
ringSetring system which placedRingAtom is part of
centerPlacedMoleculethe geometric center of the already placed molecule
atomBplaced neighbour atom of placedRingAtom

Definition at line 323 of file ModelBuilder3D.java.

References org::openscience::cdk::geometry::GeometryTools::get3DCenter(), org::openscience::cdk::tools::manipulator::RingSetManipulator::getAllInOneContainer(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IAtomContainer::getAtomCount(), org::openscience::cdk::modeling::builder3d::AtomPlacer3D::getFarthestAtom(), org::openscience::cdk::interfaces::IChemObject::getFlag(), org::openscience::cdk::interfaces::IAtom::getPoint3d(), org::openscience::cdk::CDKConstants::ISPLACED, org::openscience::cdk::modeling::builder3d::AtomTetrahedralLigandPlacer3D::rotate(), org::openscience::cdk::interfaces::IChemObject::setFlag(), org::openscience::cdk::interfaces::IAtom::setPoint3d(), and translateStructure().

Referenced by layoutMolecule().

                                                                                                                                                                 {
            //logger.debug("****** Layout ring System ******");System.out.println(">around atom:"+molecule.getAtomNumber(placedRingAtom));
            IAtomContainer ac = RingSetManipulator.getAllInOneContainer(ringSet);
            Point3d newCoord = placedRingAtom.getPoint3d();
            Vector3d axis = new Vector3d(atomB.getPoint3d().x - newCoord.x, atomB.getPoint3d().y - newCoord.y, atomB.getPoint3d().z - newCoord.z);
            translateStructure(originalCoord, newCoord, ac);
            //Rotate Ringsystem to farthest possible point
            Vector3d startAtomVector = new Vector3d(newCoord.x - atomB.getPoint3d().x, newCoord.y - atomB.getPoint3d().y, newCoord.z - atomB.getPoint3d().z);
            IAtom farthestAtom = ap3d.getFarthestAtom(placedRingAtom.getPoint3d(), ac);
            Vector3d farthestAtomVector = new Vector3d(farthestAtom.getPoint3d().x - newCoord.x, farthestAtom.getPoint3d().y - newCoord.y, farthestAtom.getPoint3d().z - newCoord.z);
            Vector3d n1 = new Vector3d();
            n1.cross(axis, farthestAtomVector);
            n1.normalize();
            double lengthFarthestAtomVector = farthestAtomVector.length();
            Vector3d farthestVector = new Vector3d(startAtomVector);
            farthestVector.normalize();
            farthestVector.scale((startAtomVector.length() + lengthFarthestAtomVector));
            double dotProduct = farthestAtomVector.dot(farthestVector);
            double angle = Math.acos(dotProduct / (farthestAtomVector.length() * farthestVector.length()));
            Vector3d ringCenter = new Vector3d();

            for (int i = 0; i < ac.getAtomCount(); i++) {
                  if (!(ac.getAtom(i).getFlag(CDKConstants.ISPLACED))) {
                        ringCenter.x = (ac.getAtom(i).getPoint3d()).x - newCoord.x;
                        ringCenter.y = (ac.getAtom(i).getPoint3d()).y - newCoord.y;
                        ringCenter.z = (ac.getAtom(i).getPoint3d()).z - newCoord.z;
                        ringCenter = AtomTetrahedralLigandPlacer3D.rotate(ringCenter, n1, angle);
                        ac.getAtom(i).setPoint3d(
                              new Point3d(
                                    ringCenter.x + newCoord.x,
                                    ringCenter.y + newCoord.y,
                                    ringCenter.z + newCoord.z
                              )
                        );
                        //ac.getAtomAt(i).setFlag(CDKConstants.ISPLACED, true);
                  }
            }

            //Rotate Ring so that geometric center is max from placed center
            //logger.debug("Rotate RINGSYSTEM");
            Point3d pointRingCenter = GeometryTools.get3DCenter(ac);
            double distance = 0;
            double rotAngleMax = 0;
            angle = 1 / 180 * Math.PI;
            ringCenter = new Vector3d(pointRingCenter.x, pointRingCenter.y, pointRingCenter.z);
            ringCenter.x = ringCenter.x - newCoord.x;
            ringCenter.y = ringCenter.y - newCoord.y;
            ringCenter.z = ringCenter.z - newCoord.z;
            for (int i = 1; i < 360; i++) {
                  ringCenter = AtomTetrahedralLigandPlacer3D.rotate(ringCenter, axis, angle);
                  if (centerPlacedMolecule.distance(new Point3d(ringCenter.x, ringCenter.y, ringCenter.z)) > distance) {
                        rotAngleMax = i;
                        distance = centerPlacedMolecule.distance(new Point3d(ringCenter.x, ringCenter.y, ringCenter.z));
                  }
            }

            //rotate ring around axis with best angle
            rotAngleMax = (rotAngleMax / 180) * Math.PI;
            for (int i = 0; i < ac.getAtomCount(); i++) {
                  if (!(ac.getAtom(i).getFlag(CDKConstants.ISPLACED))) {
                        ringCenter.x = (ac.getAtom(i).getPoint3d()).x;
                        ringCenter.y = (ac.getAtom(i).getPoint3d()).y;
                        ringCenter.z = (ac.getAtom(i).getPoint3d()).z;
                        ringCenter = AtomTetrahedralLigandPlacer3D.rotate(ringCenter, axis, rotAngleMax);
                        ac.getAtom(i).setPoint3d(
                              new Point3d(
                                    ringCenter.x,
                                    ringCenter.y,
                                    ringCenter.z
                              )
                        );
                        ac.getAtom(i).setFlag(CDKConstants.ISPLACED, true);
                  }
            }
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index