Optimal passively-safe control of multi-agent motion with application to distributed space systems