PRO smei_orient_test ;+ ; NAME: ; smei_orient_test ; PURPOSE: ; Check orientation of cameras ; CATEGORY: ; camera/idl/tricks ; CALLING SEQUENCE: ; smei_orient_test ; INPUTS: ; OPTIONAL INPUT PARAMETERS: ; OUTPUTS: ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; AngleRange, CvRotation, CombineRotations, get_camera_data ; RESTRICTIONS: ; Probably need to compile smeipoint.pro explicitly to get access to ; Don's get_camera_data ; SEE ALSO: ; smei_camera ; PROCEDURE: ; The UCSD s/c coordinate system: ; X-axis along velocity vector ; Y-axis along rotation axis spacecraft ; Z-axis to zenith ; The HAFB s/c coordinate system (as in Don's smeipoint.pro routine): ; X-axis along velocity vector ; Y-axis opposite to rotation axis spacecraft ; Z-axis pointing to nadir (i.e. down to Earth) ; ; To go from UCSD to HAFB s/c coordinate system, rotate around ; x-axis by 180 degrees: ; R[sc UCSD -> s/c HAFB]: Euler angles: [0,!pi,!pi]; quaternion: [1,0,0,0]. ; ; The UCSD camera coordinate system: ; X-axis along long dimension (on CCD positive X goes to larger pixel indices) ; Y-axis along narrow dimension (on CCD positive Y goes to smaller radius) ; Z-axis along optical axis ; The HAFB camera coordinate system (as in Don's smeipoint.pro routine): ; X-axis is UCSD Z-axis (along optical axis) ; Z-axis is UCSD Y-axis ; Y-axis is UCSD X-axis ; ; To go from HAFB to UCSD camera coordinate system, apply ; Euler angles: ; R[camera HAFB -> camera UCSD]: [0,!pi/2,!pi/2]; quaternion: [1,1,1,1]/2. ; (this is a rotation of 120 degrees around a unit vector with equal components ; along positive x,y and z axes). ; ; The Euler angles provided to Spectrum Astro rotate from the UCSD ; s/c coordinate system to the UCSD camera coordinate system. ; R[sc UCSD -> camera UCSD] ; The Euler angles provided to Spectrum Astro apply rotations to Z,X and ; Z axes. We want Euler angles applied to Z,Y,Z axes. To go from Z,Y,Z angles ; to Z,X,Z angles add 90 deg to the first and subtract 90 deg from the ; last Euler angle. ; ; The HAFB camera quaternions rotate from the HAFB camera coordinate ; system to the HAFB s/c coordinate system. ; ; R[camera HAFB -> sc HAFB] ; ; To retrieve the equivalent Spectrum Astro angles from the HAFB quaternions ; apply the following rotations in sequence: ; ; R[sc UCSD -> s/c HAFB] quaternion [1,0,0,0] ; Inverse of R[camera HAFB -> sc HAFB] (inverse of smeipoint quaternion) ; R[camera HAFB -> camera UCSD] quaternion: [1,1,1,1]/2. ; Convert the resulting quaternion to Z,Y,Z angles, i.e. ; add 90 to first and -90 to third to get Z,X,Z angles: ; ; The Euler angles given to Spectrum Astro are: ; ; camera 1: -28.207646 69.541377 -21.4776600 ; camera 2: -86.023031 58.285313 -6.5798011 ; camera 3: -143.782150 62.553932 0.3674422 ; ; We frequently need to convert from equatorial coordinates to UCSD ; camera coordinates. The quaternions provided to us in the SMEI data ; rotate from the ECI (J2000 equatorial) to the HAFB s/c frame. ; So to go from UCSD camera frame to the ECI frame apply the following ; rotations ; ; R[camera UCSD -> camera HAFB] quaternion [-1,-1,-1,1/2 ; R[camera HAFB -> s/c HAFB] (from smeipoint) ; Inverse of R[sc HAFB -> ECI] (inverse of quaternion from SMEI data) ; ; The first two of these (rotating from UCSD camera to HAFB s/c frame) ; is returned by href=smei_camera=. The inverse of all three combined ; rotations is returned by href=smei_cam_quaternion=. ; MODIFICATION HISTORY: ; MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- hafb_get_camera_data, 0, q, /all q = q[1:3].orient_quaternion print, 'camera quaternions:' print, q q[0:2,*] = -q[0:2,*] ; Invert smei quaternions q = CombineRotations([1,0,0,0], q, 0.5*[1,1,1,1], /quaternion) q = CvRotation(from_quaternion=q, /to_euler, /degrees) ; ZYZ angles q = q+90*[1,0,-1]#replicate(1,3) ; ZXZ angles q = AngleRange(q, /pi, /deg) print print, 'camera euler angles:' print, q ; Spectrum Astro equivalent Euler angles q = q-90*[1,0,-1]#replicate(1,3) ; ZXZ angles whatis, q q = CvRotation(from_euler=q, /to_quaternion, /degrees) ; ZYZ angles q = CombineRotations([-1,0,0,0], q, 0.5*[-1,-1,-1,1], /quaternion) q[0:2,*] = -q[0:2,*] ; Invert smei quaternions print print, 'camera quaternions:' print, q q[0:2,*] = -q[0:2,*] ; Invert smei quaternions q = CombineRotations([1,0,0,0], q, 0.5*[1,1,1,1], /quaternion) q = CvRotation(from_quaternion=q, /to_euler, /degrees) ; ZYZ angles q = q+90*[1,0,-1]#replicate(1,3) ; ZXZ angles q = AngleRange(q, /pi, /deg) print print, 'camera euler angles:' print, q ; Spectrum Astro equivalent Euler angles RETURN & END