The method for determining the optimal frequency of spatial modulation in the measurement of three-dimensional geometry by the method of phase triangulation is proposed. The method is based on the construction of the frequency response of the measuring system. The proposed approach makes it possible to use the optimal frequency of spatial modulation of an optical source in measurements of three-dimensional geometry by the method of phase steps and the Gray binary code. As a result, this method makes it possible to create a universal control algorithm that provides measurement of three-dimensional geometry by the method of phase steps with the smallest error.