We propose a fast and simple method to generate a 3D pencil beam with a sparse array of elements having uniform excitations and located on a rectangular grid. The presented algorithm extends a recently proposed Gaussian approach, introducing a desired pattern as the product of two suitable Gaussian functions. This reduces the problem to a couple of independent one-dimensional problems, and the optimal positions of the array elements are found in closed form. Numerical examples show the effectiveness of the method.