Not "ATN" but "ATAN", nor order of SX,SY is not correct. Write line 364 as follows. AN=DEG(ATAN(SY,SX))