Gnomonic to Equirectangular Coordinates Mapping

I’d like to understand how to map coordinates from a “normal” (I assume it’s called gnomonic) image received from 360° equirectangular image back to original.

In other words, I can take 360° image in equirectangular format and get a regular frame from it for any valid phi, theta and field of view values. Now I want to draw something on that frame and map it back to original equirectangular image. How can I do it programmatically?

“Normal” projection is called ‘rectilinear’ - not ‘gnomonic’.

With this information you will find many hints on the web depending on your programming environment.
Here’s just an example:
https://wiki.panotools.org/Extract_and_insert_rectilinear_views

Same thing, different names. I searched rectilinear along with gnomonic, couldn’t find anything better than transforming equirectangular to 6-cube faces and then translate it back, which doesn’t meet my needs.

I think another approach could be turn equirectangular image into sphere with texture, then draw a tile on a sphere with something like tree.js and then extract merged equirectangular texture.