0001 function [OutList,TotRot]=coco(InList,InCooType,OutCooType,InUnits,OutUnits);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 RADIAN = 180./pi;
0034
0035 if (nargin==1),
0036 InCooType = 'j2000.0';
0037 OutCooType = 'g';
0038 InUnits = 'r';
0039 OutUnits = 'r';
0040 elseif (nargin==2),
0041 OutCooType = 'g';
0042 InUnits = 'r';
0043 OutUnits = 'r';
0044 elseif (nargin==3),
0045 InUnits = 'r';
0046 OutUnits = 'r';
0047 elseif (nargin==4),
0048 OutUnits = 'r';
0049 elseif (nargin==5),
0050
0051 else
0052 error('Illigal number of input arguments');
0053 end
0054
0055 LenInType = length(InCooType);
0056 LenOutType = length(OutCooType);
0057
0058 if (LenInType>1),
0059 InEquinox = str2num(InCooType(2:LenInType));
0060 InEquinoxJD = 2451545.5 + 365.25.*(InEquinox - 2000);
0061 InCooType = InCooType(1);
0062 end
0063
0064 if (LenOutType>1),
0065 OutEquinox = str2num(OutCooType(2:LenOutType));
0066 OutEquinoxJD = 2451545.5 + 365.25.*(OutEquinox - 2000);
0067 OutCooType = OutCooType(1);
0068 end
0069
0070 InCoo = zeros(size(InList));
0071 OutCoo = zeros(size(InList));
0072 OutList = zeros(size(InList));
0073
0074 switch InUnits
0075 case {'r'}
0076 InCoo = InList;
0077 case {'d'}
0078
0079 InCoo = InList./RADIAN;
0080 case {'h'}
0081
0082 InCoo(:,1) = InList(:,1).*15./RADIAN;
0083 InCoo(:,2) = InList(:,2)./RADIAN;
0084 otherwise
0085 error('Unknown type of input units');
0086 end
0087
0088
0089 InCosDir = cosined(InCoo);
0090
0091
0092 RotM1 = diag([1 1 1]);
0093
0094
0095 switch InCooType
0096 case {'j','J'}
0097 if (InEquinox~=2000.0),
0098
0099 switch InCooType
0100 case {'j'}
0101
0102 RotM1 = rotm_coo('p',InEquinoxJD);
0103 case {'J'}
0104
0105 RotM1 = rotm_coo('pd',InEquinoxJD);
0106 otherwise
0107 error('Illegal InCooType');
0108 end
0109 end
0110 case {'g'}
0111
0112 RotM1 = rotm_coo('G',2451545.5);
0113 case {'e'}
0114
0115 RotM1 = rotm_coo('E',2451545.5);
0116 otherwise
0117 error('Unknown input coordinaytes type');
0118 end
0119
0120 RotM2 = diag([1 1 1]);
0121
0122 switch OutCooType
0123 case {'j','J'}
0124 if (OutEquinox~=2000.0),
0125
0126 switch OutCooType
0127 case {'j'}
0128
0129 RotM2 = rotm_coo('P',OutEquinoxJD);
0130 case {'J'}
0131
0132 RotM2 = rotm_coo('Pd',OutEquinoxJD);
0133 otherwise
0134 error('Illegal OutCooType');
0135 end
0136 end
0137 case {'g'}
0138
0139 RotM2 = rotm_coo('g',2451545.5);
0140 case {'e'}
0141
0142 RotM2 = rotm_coo('e',2451545.5);
0143 otherwise
0144 error('Unknown output coordinaytes type');
0145 end
0146
0147
0148 TotRot = RotM2*RotM1;
0149 OutCosDir = TotRot*[InCosDir.'];
0150
0151
0152
0153 OutCoo = cosined([OutCosDir.']);
0154
0155
0156 switch OutUnits
0157 case {'r'}
0158 OutList = OutCoo;
0159 case {'d'}
0160
0161 OutList = OutCoo.*RADIAN;
0162 case {'h'}
0163
0164 OutList(:,1) = OutCoo(:,1).*RADIAN./15;
0165 OutList(:,2) = OutCoo(:,2).*RADIAN;
0166 otherwise
0167 error('Unknown type of output units');
0168 end
0169
0170
0171
0172
0173
0174