Given I know almost nothing about optics this is tricky for me. For now I can give a very basic example of fisheye to rectilinear (deliberately with no trig reductions):
100%,100%,1,3,0 -sh. 0
-rm. -warp.. .,0,2 -rm.
The idea is much as you suggest; build a map of source pixel (x,y) locations for each output location (x,y). The -warp command uses that map to actually ‘pull’ the pixels in.
Maths wise this is assuming an ‘equisolid’ lens, where distance from the centre of your fisheye image (i.e. radius) is defined as r = 2f * sin (angle from optical axis/2). In the example that’s used to work out the original angle from the axis, then remap to a ‘normal’ rectilinear r = f * tan (angle). (Edit: actually it’s the backwards transform - this is just how my brain works!)
Clearly this isn’t enough explanation for either the G’MIC commands or the maths. I hope to have time to do more with it later, but can’t promise anything