This study presents a semi-analytic and sub-optimal guidance/control for a controlled/active spacecraft to avoid collision with other free/inactive space objects. The collision avoidance problem is formulated as a typical optimal feedback control problem with a penalty term incorporated into the performance index. The penalty function is designed such that its value increases sharply as a spacecraft approaches other space objects. The Pontryagin's principle is used to form a two point boundary value problem for a standard Hamiltonian system, whose solution is obtained in terms of the generating functions which appear in the theory of canonical transformation. The resultant algorithm allows one to develop near-optimal guidance/control laws as truncated power series in feedback form and generate near-optimal trajectories without any initial guess or iterative process. This procedural advantage over typical direct optimization approaches comes at the expense of reasonable efforts of developing higher-order generating functions and empirically updating the design parameters of penalty function. Numerical examples demonstrate that the proposed algorithm successfully accomplishes collision avoidance by appropriately detouring other space objects or forbidden regions.