C+ C NAME: C rotated C PURPOSE: C Calculate polar angles in rotated coordinate system C CATEGORY: C Math: coordinate transformation C CALLING SEQUENCE: subroutine rotated(ALFA,BETA,GAMMA,PHI,RLAT) C INPUTS: C ALFA double precision phase angle of the pole Z(new) in old coordinate system C BETA double precision polar angle of the pole Z(new) in old coordinate system C GAMMA double precision phase angle of X(new) in coordinate system (2) C PHI double precision phase angle in old coordinate system C RLAT double precision latitude in old coordinate system (-90<=RLAT<=90) C OUTPUTS: C PHI double precision phase angle in new coordinate system (0<=PHI<360) C RLAT double precision latitude in new coordinate system C CALLS: C dsind, dcosd, dacosd, datan2d C PROCEDURE: C Given phase and polar angles of a point in some coordinate system C [axes: X(old),Y(old),Z(old)], phase and polar angles are calculated in C the new coordinate system [axes: X(new),Y(new),Z(new)] rotated with C respect to the original one over the Euler angles ALFA, BETA, GAMMA. C The rotation from old to new system is realized by C (1) rotation around Z(old) over ALFA ---> X(1),Y(1),Z(1)=Z(old) C (2) rotation around Y(1) over BETA ---> X(2),Y(2)=Y(1),Z(2)=Z(new) C (3) rotation around Z(new) over GAMMA ---> X(new),Y(new),Z(new). C All angles are in degrees. C MODIFICATION HISTORY: C JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- double precision ALFA double precision BETA double precision GAMMA double precision PHI double precision RLAT double precision SINB double precision COSB double precision SINL double precision COSL double precision SINP double precision COSP double precision COST ! Needed for g77 when using goniod.f ! What happens if these are available as intrinsic functions?? double precision dsind double precision dcosd double precision dacosd double precision datan2d if (dabs(RLAT) .gt. 90.0d0) call Say('rotated','E','invalid','latitude') PHI = PHI-ALFA ! Rotation (1) SINB = dsind(BETA) ! Rotation (2) COSB = dcosd(BETA) SINL = dsind(RLAT) COSL = dcosd(RLAT) SINP = dsind(PHI ) COSP = dcosd(PHI ) COST = SINL*COSB+COSL*SINB*COSP ! cos(polar angle) if (dabs(COST) .ne. 1.0d0) then SINP = COSL*SINP COSP = COSL*COSB*COSP-SINL*SINB else !Point on new Z-axis; PHI not defined !------- ! The following statement is inserted for the benefit of the ! synoptic map drawing program. ! If BETA=0 then SINB=0, COSB=+/-1, i.e. the z-axis stays the same ! or is flipped by 180 degrees. The input phase angle for points on ! the z-axis will remain the same or is changed to 180-(phase angle) ! (just as for points not on the z-axis). if (SINB .eq. 0.0d0) COSP = COSB*COSP end if PHI = datan2d(SINP,COSP) PHI = PHI-GAMMA ! Rotation (3) PHI = dmod(dmod(PHI,360.0d0)+360.0d0,360.0d0)!0<=PHI<360 RLAT = 90.0d0-dacosd(COST) ! acosd returns between 0 and 180 deg return end