source: trunk/SRC/ToBeReviewed/PLOTS/DIVERS/rotation.pro @ 163

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 887 bytes
Line 
1;+
2;
3; @file_comments
4; Rotate two vectors by a specified amount.
5;           
6; @param X {in}{required}
7; original data point pairs
8;
9; @param Y {in}{required}
10; original data point pairs
11;           
12; @param DEG {in}{required}
13; degrees to rotate.
14;           
15; @param NX {out}
16; rotated point pairs.
17;
18; @param NY {out}
19; rotated point pairs.
20;           
21; @history
22; Jeff Bennett, U of Colorado
23;
24; @version
25; $Id$
26;
27;-
28
29PRO rotation,X,Y,DEG,NX,NY
30;
31  compile_opt idl2, strictarrsubs
32;
33ang=deg*!dtor
34
35;convert to polar coordinates for rotation
36r = sqrt(x*x + y*y)
37theta = r*0.
38;get angle in for loop so that zero radii will be left as zero angle
39for i = 0,n_elements(r)-1 do $
40if r[i] ne 0 then theta[i] = atan(y[i],x[i])  ;range from -pi to +pi
41;
42;add rotation angle
43theta = theta + ang
44;
45;convert back to rectangular coordinates, now rotated
46nx = r * cos(theta)
47ny = r * sin(theta)
48;
49return
50end
Note: See TracBrowser for help on using the repository browser.