after a bit of fiddling, it seems that its the yRot on the camera that gives the slightly off results. when the camera is down, close to the map/ground, and rotated to be looking towards the horizon, the more oblique the angle, the more off the returned result.
im not sure if there is a proper way to correct for this in the script, but i did this…
C = thisComp.layer("TRGT: Goal");
v = C.toWorldVec([1,0,0]);
rot = radiansToDegrees(Math.atan2(v[1],v[0]))
rot -(thisComp.layer("TRGT: Goal").transform.yRotation/2)
(the camera is animated with sure target, so i changed the c from looking at the camera, to looking at the target. doesnt seem to make a differnce in the results, but just fyi).
i tried it without the /2, but that corrected by TOO much. so half seems to yeild better results, at least in this particular circumstance. its by no means a global fix, as it completely doesnt work on a different object earlier in the animation.