Just use c_rotate(entity, vector(pan,tilt,roll), glide); you dont need those calculations, see in the manual about c_rotate.

And a vector its 3 values(var vec[3]) with magnitude and direction. Do not know what pan_earth[6] have to do with this question.