  A unique perspective approach based on an analogy method is presented to
solve the ray equation in a model of a continuous inhomogeneous medium, which
has a spherically symmetric distribution. Basically, in the standard
undergraduate physics teaching, the curved ray path caused by refraction in a
medium with a continuously varying refractive index has always been a
relatively difficult problem to solve. The equation is usually expressed in
terms of partial differential equations (PDEs), which cannot be solved by
analytical methods. Based on the analogy method, this work proposes the
correspondence between ray refraction in an established medium model and the
inverse-square central force system, succinctly obtaining their relation
equations mathematically. We also verify the correctness of the method by
qualitative and quantitative analysis. In terms of theoretical validation, we
analyse the relation between Fermat's principle and Hamilton's principle, which
lays a theoretical foundation for the analogy method. In addition, ray paths in
the medium model were also simulated by numerical calculations based on COMSOL
Multiphysics, and the results are in perfect agreement with the conclusions.
