Yeah it's complicated and annoying.
Basically you need a function to find the distance (positive or negative) between 2 angles:
DEF ANGDIST(A1#,A2#) A1#=A1#-A2#+PI() RETURN A1#-2*PI()*FLOOR(A1#/(2*PI()))-PI() END 'Or, a simpler but possibly slightly less precise version: DEF ANGDIST(A1,A2) RETURN ATAN(SIN(A1-A2),COS(A1-A2)) ENDAnd then you check whether ANGDIST(ROT,TROT) is greater than or less than 0.