In the Hartmann test, a wave aberration function W is estimated from the information of the spot diagram drawn in an observation plane. The distance from a reference plane to the observation plane, the Hartmann-plane distance, is typically chosen as z=f, where f is the radius of a reference sphere. The function W and the transversal aberrations {X,Y} calculated at the plane z=f are related by two well-known linear differential equations. Here, we propose two nonlinear differential equations to denote a more general relation between W and the transversal aberrations {U,V} calculated at any arbitrary Hartmann-plane distance z=r. We also show how to directly estimate the wavefront surface w from the information of {U,V}. The use of arbitrary r values could improve the reliability of the measurements of W, or w, when finding difficulties in adequate ray identification at z=f.