public double[] calculate(IAtomContainer container, IAtom atom) {
        int length = (int) ((cutoff - startCutoff) / resolution) + 1;
        logger.debug("Creating RDF of length ", length);

        // the next we need for Gaussian smoothing
        int binsToFillOnEachSide = (int) (peakWidth * 3.0 / resolution);
        double sigmaSquare = Math.pow(peakWidth, 2.0);
        // factors is only half a Gaussian, taking advantage of being symmetrical!
        double[] factors = new double[binsToFillOnEachSide];
        double totalArea = 0.0;
        if (factors.length > 0) {
            factors[0] = 1;
            for (int binCounter = 1; binCounter < factors.length; binCounter++) {
                double height = Math.exp(-1.0 * (Math.pow(((double) binCounter) * resolution, 2.0)) / sigmaSquare);
                factors[binCounter] = height;
                totalArea += height;
            }
            // normalize the Gaussian to unit area
            for (int binCounter = 0; binCounter < factors.length; binCounter++) {
                factors[binCounter] = factors[binCounter] / totalArea;
            }
        }

        // this we need always
        double[] rdf = new double[length];
        double distance = 0.0;
        int index = 0;

        Point3d atomPoint = atom.getPoint3d();
        Iterator<IAtom> atomsInContainer = container.atoms().iterator();
        while (atomsInContainer.hasNext()) {
            IAtom atomInContainer = (IAtom) atomsInContainer.next();
            if (atomInContainer.equals(atom)) continue; // don't include the central atom
            distance = atomPoint.distance(atomInContainer.getPoint3d());
            index = (int) ((distance - startCutoff) / this.resolution);
            double weight = 1.0;
            if (weightFunction != null) {
                weight = weightFunction.calculate(atom, atomInContainer);
            }
            if (factors.length > 0) {
                // apply Gaussian smoothing
                rdf[index] += weight * factors[0];
                for (int binCounter = 1; binCounter < factors.length; binCounter++) {
                    double diff = weight * factors[binCounter];
                    if ((index - binCounter) >= 0) {
                        rdf[index - binCounter] += diff;
                    }
                    if ((index + binCounter) < length) {
                        rdf[index + binCounter] += diff;
                    }
                }
            } else {
                rdf[index] += weight; // unweighted
            }
        }
        return rdf;
    }
public double [ ] calculate ( IAtomContainer container , IAtom atom ) { int length = ( int ) ( ( cutoff - startCutoff ) / resolution ) + 1 ; logger . debug ( "Creating RDF of length " , length ) ; int binsToFillOnEachSide = ( int ) ( peakWidth * 3.0 / resolution ) ; double sigmaSquare = Math . pow ( peakWidth , 2.0 ) ; double [ ] factors = new double [ binsToFillOnEachSide ] ; double totalArea = 0.0 ; if ( factors . length > 0 ) { factors [ 0 ] = 1 ; for ( int binCounter = 1 ; binCounter < factors . length ; binCounter ++ ) { double height = Math . exp ( - 1.0 * ( Math . pow ( ( ( double ) binCounter ) * resolution , 2.0 ) ) / sigmaSquare ) ; factors [ binCounter ] = height ; totalArea += height ; } for ( int binCounter = 0 ; binCounter < factors . length ; binCounter ++ ) { factors [ binCounter ] = factors [ binCounter ] / totalArea ; } } double [ ] rdf = new double [ length ] ; double distance = 0.0 ; int index = 0 ; Point3d atomPoint = atom . getPoint3d ( ) ; Iterator < IAtom > atomsInContainer = container . atoms ( ) . iterator ( ) ; while ( atomsInContainer . hasNext ( ) ) { IAtom atomInContainer = ( IAtom ) atomsInContainer . next ( ) ; if ( atomInContainer . equals ( atom ) ) continue ; distance = atomPoint . distance ( atomInContainer . getPoint3d ( ) ) ; index = ( int ) ( ( distance - startCutoff ) / this . resolution ) ; double weight = 1.0 ; if ( weightFunction != null ) { weight = weightFunction . calculate ( atom , atomInContainer ) ; } if ( factors . length > 0 ) { rdf [ index ] += weight * factors [ 0 ] ; for ( int binCounter = 1 ; binCounter < factors . length ; binCounter ++ ) { double diff = weight * factors [ binCounter ] ; if ( ( index - binCounter ) >= 0 ) { rdf [ index - binCounter ] += diff ; } if ( ( index + binCounter ) < length ) { rdf [ index + binCounter ] += diff ; } } } else { rdf [ index ] += weight ; } } return rdf ; }
Calculates a RDF for <code>Atom</code> atom in the environment
of the atoms in the <code>AtomContainer</code>.