C+ C NAME: C smei_hdr_quaternion C PURPOSE: C Extract quaternion from SMEI frame header C CALLING SEQUENCE: subroutine smei_hdr_quaternion(hdr,id,qq) C INPUTS: C hdr(*) double precision C SMEI frame header 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 C Coriolis s/c or camera quaternion C INCLUDE: include 'smei_frm_hdr.h' C CALLS: C quaternion_multiply, quaternion_inverse C SEE ALSO: C quaternion_rotate_xyz C PROCEDURE: C > For id=0 the quaternion qcoriolis stored in the frame header is returned. C This rotates vectors from equatorial sky coordinates to HAFB C spacecraft coordinates. C > Hardcoded in this procedure are quaternions qcam that rotate vectors C from HAFB spacecraft coordinates to HAFB camera coordinates. C > An additional hardcoded quaternion qucsd rotates vectors from HAFB C camera coordinates to UCSD camera coordinates. C > For id=1 these three quaternions are multiplied together to get C the quaternion qq1=qcoriolis*qcam*qucsd that rotates from equatorial sky C coordinates to UCSD camera coordinates, C i.e, if (rx,ry,rz) is a unit vector in equatorial sky coordinates then C call quaternion_rotate_xyz(qq1,rx,ry,rz) C will return (rx,ry,rz) in the UCSD camera frame. C > For id=2 the inverse quaternion qq2 of the id=1 quaternion is returned, C which rotates vectors from UCSD camera coordinate to equatorial sky C coordinates. C i.e, if (rx,ry,rz) is a unit vector in the UCSD camera frame then C call quaternion_rotate_xyz(qq2,rx,ry,rz) C will return (rx,ry,rz) in the equatorial frame. C MODIFICATION HISTORY: C DEC-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- double precision hdr(*) integer id double precision qq(*) ! qcam rotates from HAFB spacecraft coordinates to HAFB camera coordinates. ! 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 qq(1) = hdr( SMEI__HDR_QUAT+0 ) ! Equat sky frame -> HAFB spacecraft frame qq(2) = hdr( SMEI__HDR_QUAT+1 ) qq(3) = hdr( SMEI__HDR_QUAT+2 ) qq(4) = hdr( SMEI__HDR_QUAT+3 ) if (id .gt. 0) then ! HAFB spacecraft frame -> HAFB camera frame call quaternion_multiply(qq,qcam(1,nint(hdr(SMEI__HDR_CAMERA))),qq) 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