private void setBranchAtom(IAtomContainer molecule, IAtom unplacedAtom, IAtom atomA, IAtomContainer atomNeighbours,
            AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d) throws CDKException {
        //logger.debug("****** SET Branch Atom ****** >"+molecule.indexOf(unplacedAtom));
        IAtomContainer noCoords = molecule.getBuilder().newInstance(IAtomContainer.class);
        noCoords.addAtom(unplacedAtom);
        Point3d centerPlacedMolecule = ap3d.geometricCenterAllPlacedAtoms(molecule);
        IAtom atomB = atomNeighbours.getAtom(0);

        String atypeNameA = atomA.getAtomTypeName();
        String atypeNameB = atomB.getAtomTypeName();
        String atypeNameUnplaced = unplacedAtom.getAtomTypeName();

        double length = ap3d.getBondLengthValue(atypeNameA, atypeNameUnplaced);
        double angle = (ap3d.getAngleValue(atypeNameB, atypeNameA, atypeNameUnplaced)) * Math.PI / 180;
        /*
         * System.out.println("A:"+atomA.getSymbol()+" "+atomA.getAtomTypeName()+
         * " B:"+atomB.getSymbol()+" "+atomB.getAtomTypeName()
         * +" unplaced Atom:"
         * +unplacedAtom.getAtomTypeName()+" BL:"+length+" Angle:"+angle
         * +" FormalNeighbour:"
         * +atomA.getFormalNeighbourCount()+" HYB:"+atomA.getFlag
         * (CDKConstants.HYBRIDIZATION_SP2)
         * +" #Neigbhours:"+atomNeighbours.getAtomCount());
         */
        IAtom atomC = ap3d.getPlacedHeavyAtom(molecule, atomB, atomA);

        Point3d[] branchPoints = atlp3d.get3DCoordinatesForLigands(atomA, noCoords, atomNeighbours, atomC,
                (atomA.getFormalNeighbourCount() - atomNeighbours.getAtomCount()), length, angle);
        double distance = 0;
        int farthestPoint = 0;
        for (int i = 0; i < branchPoints.length; i++) {
            if (Math.abs(branchPoints[i].distance(centerPlacedMolecule)) > Math.abs(distance)) {
                distance = branchPoints[i].distance(centerPlacedMolecule);
                farthestPoint = i;
            }
        }

        int stereo = -1;
        IBond unplacedBond = molecule.getBond(atomA, unplacedAtom);
        if (atomA.getStereoParity() != CDKConstants.UNSET && atomA.getStereoParity() != 0
                || (unplacedBond.getStereo() == IBond.Stereo.UP || unplacedBond.getStereo() == IBond.Stereo.DOWN)
                && molecule.getMaximumBondOrder(atomA) == IBond.Order.SINGLE) {
            if (atomNeighbours.getAtomCount() > 1) {
                stereo = atlp3d.makeStereocenter(atomA.getPoint3d(), molecule.getBond(atomA, unplacedAtom),
                        (atomNeighbours.getAtom(0)).getPoint3d(), (atomNeighbours.getAtom(1)).getPoint3d(),
                        branchPoints);
            }
        }
        if (stereo != -1) {
            farthestPoint = stereo;
        }
        unplacedAtom.setPoint3d(branchPoints[farthestPoint]);
        unplacedAtom.setFlag(CDKConstants.ISPLACED, true);
    }
private void setBranchAtom ( IAtomContainer molecule , IAtom unplacedAtom , IAtom atomA , IAtomContainer atomNeighbours , AtomPlacer3D ap3d , AtomTetrahedralLigandPlacer3D atlp3d ) throws CDKException { IAtomContainer noCoords = molecule . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; noCoords . addAtom ( unplacedAtom ) ; Point3d centerPlacedMolecule = ap3d . geometricCenterAllPlacedAtoms ( molecule ) ; IAtom atomB = atomNeighbours . getAtom ( 0 ) ; String atypeNameA = atomA . getAtomTypeName ( ) ; String atypeNameB = atomB . getAtomTypeName ( ) ; String atypeNameUnplaced = unplacedAtom . getAtomTypeName ( ) ; double length = ap3d . getBondLengthValue ( atypeNameA , atypeNameUnplaced ) ; double angle = ( ap3d . getAngleValue ( atypeNameB , atypeNameA , atypeNameUnplaced ) ) * Math . PI / 180 ; IAtom atomC = ap3d . getPlacedHeavyAtom ( molecule , atomB , atomA ) ; Point3d [ ] branchPoints = atlp3d . get3DCoordinatesForLigands ( atomA , noCoords , atomNeighbours , atomC , ( atomA . getFormalNeighbourCount ( ) - atomNeighbours . getAtomCount ( ) ) , length , angle ) ; double distance = 0 ; int farthestPoint = 0 ; for ( int i = 0 ; i < branchPoints . length ; i ++ ) { if ( Math . abs ( branchPoints [ i ] . distance ( centerPlacedMolecule ) ) > Math . abs ( distance ) ) { distance = branchPoints [ i ] . distance ( centerPlacedMolecule ) ; farthestPoint = i ; } } int stereo = - 1 ; IBond unplacedBond = molecule . getBond ( atomA , unplacedAtom ) ; if ( atomA . getStereoParity ( ) != CDKConstants . UNSET && atomA . getStereoParity ( ) != 0 || ( unplacedBond . getStereo ( ) == IBond . Stereo . UP || unplacedBond . getStereo ( ) == IBond . Stereo . DOWN ) && molecule . getMaximumBondOrder ( atomA ) == IBond . Order . SINGLE ) { if ( atomNeighbours . getAtomCount ( ) > 1 ) { stereo = atlp3d . makeStereocenter ( atomA . getPoint3d ( ) , molecule . getBond ( atomA , unplacedAtom ) , ( atomNeighbours . getAtom ( 0 ) ) . getPoint3d ( ) , ( atomNeighbours . getAtom ( 1 ) ) . getPoint3d ( ) , branchPoints ) ; } } if ( stereo != - 1 ) { farthestPoint = stereo ; } unplacedAtom . setPoint3d ( branchPoints [ farthestPoint ] ) ; unplacedAtom . setFlag ( CDKConstants . ISPLACED , true ) ; }
Sets a branch atom to a ring or aliphatic chain.

@param  unplacedAtom    The new branchAtom
@param  atomA           placed atom to which the unplaced atom is connected
@param  atomNeighbours  placed atomNeighbours of atomA