I think the formula is too complicated. I purpose a simpler formula, like: If bearing <=180 AverageBearing = (bearing + (backbearing -180))/2 else AverageBearing = (bearing + (backbearing +180))/2Your proposed formula gives wrong answers in some cases - consider: bearing = 80, backbearing = 0 These give AverageBearing = (80 + 0 - 180) / 2 = -50 (equivalent to 310), but this should be 130 (average of 80 and 180).
The therion formula is attempting to average the angles by trigonometry, which seems a reasonable approach (though probably slower than trying to average more directly like you're suggesting). It looks essentially correct to me, though it's a bit oddly written since cos(90 - x) is sin(x), sin(90 - x) is -cos(x), 90 - atan2(y,x) is atan2(x,y) (possibly +/- a multiple of 360). But if I work it out with a calculator for 236.8 and 56.8 then I do get 236.8.
If it's still not working with the declination set to zero, perhaps you should show us a complete small example we can process to see what is going on?
I attach the original file with the fore/back sight (SCAGUA.th)
and a manually averaged (SCAGUA_avg.th) to compare if Survex and
Therion work well. The error loop is similar between the two files
(2,9m) but I have to check if the station are positioned at the
same coordinates.
Regards,
Evaristo.