Method of evolving junctions: a new approach to path planning and optimal control