Non-iterative and exact method for constraining particles in a linear geometry: Constraining Particles in a Linear Geometry