generalized to 3D

still need to check diffraction pattern