Hamiltonian foundation of geometrical anisotropic optics