Using a kinematic approach, I derive two sets of partial differential equations whose solutions define the kinematics of residual-migration operators. These operators can transform an image migrated with one velocity model to an image migrated with another velocity model. Under the assumption of knowing the partial derivatives of traveltimes with respect to the coordinates of velocity models on a regular grid, these two sets of partial differential equations can then be solved with standard finite-difference techniques. This algorithm can efficiently calculate the residual-migration operators for common shot gathers or constant offset sections migrated with general velocity models. Examples with residual profile migration prove that the accuracy of the algorithm is sufficient for seismic applications.