clarification, or worse:
The posted code, which might not work at all, but did seem to for something, is not Lite-C. It is C-Script, for rotating an entity toward a point, gradually, with no overshoot, but only for pan, ...or maybe it's alphabet soup instead.
(Function vf (vector function) Pan2 (pan to) is supposed to be similar to the above function actor_turnto?)

quoting manual for function ang (should be a command for C-Script and Lite-C):
 Quote:

ang(x)
Shifts the angle x into the -180 .. +180 range by adding or subtracting a multiple of 360 degrees. Often useful for calculating angle differences.
Returns:
Same angle, shifted into the -180 .. +180 range.


A thread in category Lite-C contributions is referred to for Lite-C and quaternions.
Perhaps there was a misunderstanding here, and the information offered is irrelevant.
'My' knowledge on many topics is very limited.