  A variational principle is applied to 4D Euclidean space provided with a
tensor refractive index, defining what can be seen as 4-dimensional optics
(4DO). The geometry of such space is analysed, making no physical assumptions
of any kind. However, by assigning geometric entities to physical quantities
the paper allows physical predictions to be made. A mechanism is proposed for
translation between 4DO and GR, which involves the null subspace of 5D space
with signature $(-++++)$. A tensor equation relating the refractive index to
sources is established geometrically and the sources tensor is shown to have
close relationship to the stress tensor of GR. This equation is solved for the
special case of zero sources but the solution that is found is only applicable
to Newton mechanics and is inadequate for such predictions as light bending and
perihelium advance. It is then argued that testing gravity in the physical
world involves the use of a test charge which is itself a source. Solving the
new equation, with consideration of the test particle's inertial mass, produces
an exponential refractive index where the Newtonian potential appears in
exponent and provides accurate predictions. Resorting to hyperspherical
coordinates it becomes possible to show that the Universe's expansion has a
purely geometric explanation without appeal to dark matter.
