Systems, methods, and software for determining a set of analytical or numerical polynomials that is orthonormal over circular or noncircular pupils are described. Closed-form orthonormal polynomials for circular, annular, hexagonal, elliptical, rectangular, and square pupils are derived. Such techniques can be applied to ray tracing as in the optical design and wavefront fitting from measurement as in the optical testing. These approaches can also be applied to wavefront reconstruction in adaptive optics.