We consider the inverse refractor and the inverse reflector problem. The task is to design a free-form lens or a free-form mirror that, when illuminated by a point light source, produces a given illumination pattern on a target. Both problems can be modeled by strongly nonlinear second-order partial differential equations of Monge-Ampère type. In [Math. Models Methods Appl. Sci.25, 803 (2015)MMMSEU0218-202510.1142/S0218202515500190], the authors have proposed a B-spline collocation method, which has been applied to the inverse reflector problem. Now this approach is extended to the inverse refractor problem. We explain in depth the collocation method and how to handle boundary conditions and constraints. The paper concludes with numerical results of refracting and reflecting optical surfaces and their verification via ray tracing.