Impurity nearest-neighbor distances studied by extended x-ray absorption fine structure: Application to electron-spin resonance