public List < Contact > getContactsWithinCell ( ) { List < Contact > contacts = new ArrayList < Contact > ( ) ; Point3d [ ] iAtoms = grid . getIAtoms ( ) ; Point3d [ ] jAtoms = grid . getJAtoms ( ) ; double cutoff = grid . getCutoff ( ) ; if ( jAtoms == null ) { for ( int i : iIndices ) { for ( int j : iIndices ) { if ( j > i ) { double distance = iAtoms [ i ] . distance ( iAtoms [ j ] ) ; if ( distance < cutoff ) contacts . add ( new Contact ( i , j , distance ) ) ; } } } } else { for ( int i : iIndices ) { for ( int j : jIndices ) { double distance = iAtoms [ i ] . distance ( jAtoms [ j ] ) ; if ( distance < cutoff ) contacts . add ( new Contact ( i , j , distance ) ) ; } } } return contacts ; }
Calculates all distances of atoms within this cell returning those that are within the given cutoff as a list of Contacts containing the indices of the pair and the calculated distance .