;+ ; ; @file_comments ; Rotate two vectors by a specified amount. ; ; @param X {in}{required} ; original data point pairs ; ; @param Y {in}{required} ; original data point pairs ; ; @param DEG {in}{required} ; degrees to rotate. ; ; @param NX {out} ; rotated point pairs. ; ; @param NY {out} ; rotated point pairs. ; @history ; Jeff Bennett, U of Colorado ; ; @version ; $Id$ ; ;- PRO rotation,X,Y,DEG,NX,NY ; compile_opt idl2, strictarrsubs ; ang=deg*!dtor ;convert to polar coordinates for rotation r = sqrt(x*x + y*y) theta = r*0. ;get angle in for loop so that zero radii will be left as zero angle for i = 0,n_elements(r)-1 do $ if r[i] ne 0 then theta[i] = atan(y[i],x[i]) ;range from -pi to +pi ; ;add rotation angle theta = theta + ang ; ;convert back to rectangular coordinates, now rotated nx = r * cos(theta) ny = r * sin(theta) ; return end