C+ C NAME: C Time2smei_quaternion C PURPOSE: C Get estimate of Coriolis spacecraft C CATEGORY: C gen/for/lib C CALLING SEQUENCE: subroutine Time2smei_quaternion(tt,camera,id,qq) C INPUTS: C tt(2) integer UT time C camera integer camera number C id integer =0: return Coriolis quaternion C =1: return sky-to-cam quaternion C =2: return cam-to-sky quaternion C OUTPUTS: C qq(4) double precision quaternion C CALLS: C Time2smei_eph, rotate_Euler2dcm, rotate_dcm2quat C quaternion_multiply, quaternion_inverse C SEE ALSO: C smei_hdr_quaternion C PROCEDURE: C > For id=0 the resulting spacecraft quaternion connect the C HAFB camera frame with the ECI (J2000 Equat) coordinate C frame, i.e. this is the quaternion that is found in C the header of the SMEI frame. C The assumption is made that the spacecraft is in its C nominal attitude with the HAFB z-axis pointing to the nadir C and the HAFB x-axis along the velocity vector. C > For id=1 and 2 the resulting quaternion connects the C UCSD camera frame with the ECI coordinate frame C MODIFICATION HISTORY: C JUL-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- integer tt(2) integer camera integer id double precision qq(4) logical Time2smei_eph double precision dcm(3,3) double precision rr(6) double precision rlen double precision alfa double precision beta double precision gamma double precision datan2d double precision dacosd ! qcam rotates from HAFB spacecraft frame to HAFB camera frame. ! double precision qcam(4,3) /-0.4677060d0,-0.848236d0,-0.0724612d0,-0.237689d0, ! & -0.0170381d0,-0.962053d0,-0.0476403d0,-0.268131d0, ! & -0.4372860d0, 0.869462d0, 0.1062590d0, 0.203781d0/ ! 2005/04, improved quaternions for cam 1 and 2. ! 2005/05, improved quaternions for cam 3. double precision qcam(4,3) /-0.46796080d0,-0.84822450d0,-0.07155320d0,-0.23750370d0, & -0.01748647d0,-0.96205384d0,-0.04594647d0,-0.26839441d0, & -0.43708150d0, 0.86946470d0, 0.10603300d0, 0.20432280d0/ double precision qucsd(4) /4*0.5d0/ ! HAFB camera frame -> UCSD camera frame ! Location of SMEI in ECI (J2000 Equat) coord ! rr(1:3) is direction of zenith ! rr(4:6) is velocity vector if (.not. Time2smei_eph(tt,rr,.FALSE.)) stop 'Time2smei_quaternion: no tlm?' ! Change to direction of nadir (z-axis in HAFB ! spacecraft frame. The velocity vector is the x-axis ! in the HAFB frame. rr(1) = -rr(1) rr(2) = -rr(2) rr(3) = -rr(3) ! Change position and velocity vectors to unit vectors. rlen = dsqrt( rr(1)*rr(1)+rr(2)*rr(2)+rr(3)*rr(3) ) rr(1) = rr(1)/rlen rr(2) = rr(2)/rlen rr(3) = rr(3)/rlen rlen = dsqrt( rr(4)*rr(4)+rr(5)*rr(5)+rr(6)*rr(6) ) rr(4) = rr(4)/rlen rr(5) = rr(5)/rlen rr(6) = rr(6)/rlen ! alfa is RA of nadir ! beta is polar angle of nadir ! gamma-180 is position angle of velocity vector with equat north alfa = datan2d(rr(2),rr(1)) beta = dacosd(rr(3)) gamma = 180.0d0+datan2d(rr(2)*rr(4)-rr(1)*rr(5),rr(6)) ! Convert Euler angles to direction cosine matrix. ! Then convert dcm to quaternion. ! The resulting quaternion should match the quaternion values ! found in the SMEI CCD frames (if the spacecraft is in its nominal ! attitude). call rotate_euler2dcm(alfa,beta,gamma,dcm) call rotate_dcm2quat(dcm,qq) ! Equat sky frame -> HAFB spacecraft frame if (id .gt. 0) then call quaternion_multiply(qq,qcam(1,camera),qq) ! HAFB spacecraft frame -> HAFB camera frame call quaternion_multiply(qq,qucsd,qq) ! HAFB camera frame -> UCSD camera frame if (id .eq. 2) call quaternion_inverse(qq,qq) ! Invert quaternion end if return end