Generalized velocity obstacle algorithm for preventing ship collisions at sea