public static double getBondLengthAverage3D ( IAtomContainer container ) { double bondLengthSum = 0 ; int bondCounter = 0 ; for ( IBond bond : container . bonds ( ) ) { IAtom atom1 = bond . getBegin ( ) ; IAtom atom2 = bond . getEnd ( ) ; if ( atom1 . getPoint3d ( ) != null && atom2 . getPoint3d ( ) != null ) { bondCounter ++ ; bondLengthSum += atom1 . getPoint3d ( ) . distance ( atom2 . getPoint3d ( ) ) ; } } return bondLengthSum / bondCounter ; }
An average of all 3D bond length values is produced using point3ds in atoms . Atom s with no coordinates are disregarded .