We describe a complex geologic model as an aggregate of arbitrarily shaped blocks separated by cubic splines in 2D and triangulated interfaces in 3D. Recently we have introduced a segmentally iterative ray-tracing (SIRT) method based on Fermat’s principle of stationary travel time, which has been documented to be robust and fast for a complex block model with a constant velocity defined in each block. In this work, we extend the constant velocity to a generally continuous distribution with an analytical expression of travel time, and develop SIRT in the redefined velocity distribution. As a three-point perturbation scheme, SIRT requires an explicit analytical travel time between two intersection points expressed as a function of coordinates of the two points. In these situations, we derive a general midpoint perturbation formula, and further a detailed perturbation formula for familiar media with a constant velocity gradient. SIRT is a scheme in which we perturb the intersection points of an initial-guess ray path in sequence by the first-order explicit formulas instead of using traditional iterative methods. A key consideration is the fact that the number of intersection points may be variable during the iteration process. Numerical tests demonstrate that SIRT is effective in implementing kinematic two-point ray tracing in complex 2D and 3D heterogeneous media.