Finding neighbors and distances form borders for particles