For more complicated shapes, or other refractive index values, the same result can be derived by calculating the optical phase shift in each direction using Fermat's principle and taking into account the different phase velocities for the different propagation directions in an inertial laboratory frame, which can be calculated using relativistic addition of velocities.