Analytical ray-tracing in planetary atmospheres