Formation control of multirobot systems has drawn significant attention in the recent years. This paper presents a potential field control algorithm, navigating a swarm of robots into a predefined 2D shape while avoiding intermember collisions. The algorithm applies in both stationary and moving targets formation. We define the bounded artificial forces in the form of exponential functions, so that the behavior of the swarm drove by the forces can be adjusted via selecting proper control parameters. The theoretical analysis of the swarm behavior proves the stability and convergence properties of the algorithm. We further make certain modifications upon the forces to improve the robustness of the swarm behavior in the presence of realistic implementation considerations. The considerations include obstacle avoidance, local minima, and deformation of the shape. Finally, detailed simulation results validate the efficiency of the proposed algorithm, and the direction of possible futrue work is discussed in the conclusions.