18 static PGSt_double project[3][3];
22 int32
const num_frames,
125 static char filefunc[] = __FILE__
", GEO_cumulate_GRing";
126 static double inverse[3][3];
128 PGSt_SMF_status retval=PGS_S_SUCCESS;
131 PGSt_double positionECR[3];
132 PGSt_double velocityECR[3];
143 char msgbuf[PGS_SMF_MAX_MSGBUF_SIZE]=
"";
148 sprintf(msgbuf,
"params:%p, num_frames:%ld, sc_ev_frame_state:%p, "
149 "frame_flags:%p, ecr_frame_position:%p",
150 (
void*)
params, (
long)num_frames, (
void*)sc_ev_frame_state,
151 (
void*)frame_flags, (
void*)ecr_frame_position);
157 for (frame = 0; frame < num_frames; frame++)
168 for (col=0; col<3; col++) {
170 (PGSt_double)sc_ev_frame_state[frame].positionECR[col];
172 (PGSt_double)sc_ev_frame_state[frame].velocityECR[col];
174 PGS_CSC_crossProduct(positionECR, velocityECR, quat+1);
175 radius = PGS_CSC_Norm(positionECR);
176 pcrossv = PGS_CSC_Norm(quat+1);
178 if (radius < 0.5 * params->orbit_valid_params.position_mag_limit[0] ||
179 pcrossv < params->orbit_valid_params.ang_mom_limit[0])
181 sprintf(msgbuf,
"sc_ev_frame_state[%d].positionECR too small",
190 memcpy(project[1], velocityECR,
sizeof(project[1]));
193 for(endframe=num_frames-1;
198 for (col=0; col<3; col++)
199 project[2][col] = ecr_frame_position[det][endframe][col]
200 - ecr_frame_position[det][frame][col];
202 PGS_CSC_crossProduct(project[1], project[2], project[0]);
203 length = PGS_CSC_Norm(project[0]);
205 if(length < DBL_EPSILON)
210 memcpy(project[0], positionECR,
sizeof(project[0]));
211 memcpy(project[2], quat+1,
sizeof(project[2]));
213 else if(PGS_CSC_dotProduct(project[0], positionECR, 3) < 0.0)
215 for (col=0; col<3; col++)
217 project[0][col] *= -1.0;
218 project[2][col] *= -1.0;
225 quat[0] = cos(0.5*theta);
226 for (col=1; col<4; col++)
227 quat[col] *= sin(0.5*theta)/pcrossv;
228 for(row=0; row<3; row++)
230 if(PGS_CSC_quatRotate(quat, project[row], temp)!=PGS_S_SUCCESS)
232 modsmf(
MODIS_E_GEO,
"PGS_CSC_quatRotate()", filefunc);
235 length = PGS_CSC_Norm(temp);
236 if(length < DBL_EPSILON)
241 for(col=0; col<3; col++)
242 project[row][col] = temp[col]/length;
247 for (row=0; row<3; row++)
248 for (col=0; col<3; col++)
249 matrix[row][col] = (
double)project[row][col];
253 IMSL_INVERSE_USER, inverse[0],
258 modsmf(
MODIS_E_GEO,
"imsl_d_lin_sol_gen()", filefunc);
263 for (row=0; row<3; row++)
266 for (col=0; col<3; col++)
267 rts[row] += inverse[col][row] *
268 ecr_frame_position[det][frame][col];
271 if (rts[0] > (0.01 *
params->orbit_valid_params.position_mag_limit[0]))
275 tmin = (tmin < rts[1]) ? tmin : rts[1];
276 tmax = (tmax > rts[1]) ? tmax : rts[1];
277 smin = (smin < rts[2]) ? smin : rts[2];
278 smax = (smax > rts[2]) ? smax : rts[2];
282 sprintf(msgbuf,
"ecr_frame_position[%d][%d]: rts[0]=%g",
368 PGSt_double corner_point[
CORNERS][3], posECR[3];
369 PGSt_double length, ray[3];
370 PGSt_double missAlt, slantRg;
371 PGSt_double posNEAR[3], posSURF[3];
374 PGSt_SMF_status rtnfun;
376 if (GRing_points ==
NULL)
379 "GEO_get_GRing_points.c, GEO_get_GRing_points");
383 new_points = *GRing_points;
390 modsmf(
MODIS_W_NO_GEO,
"",
"GEO_get_GRing_points.c, GEO_get_GRing_points");
403 for (
j=0;
j<3;
j++) {
404 corner_point[0][
j] = project[0][
j] + tmin*project[1][
j] + smin*project[2][
j];
405 corner_point[1][
j] = project[0][
j] + tmin*project[1][
j] + smax*project[2][
j];
406 corner_point[2][
j] = project[0][
j] + tmax*project[1][
j] + smax*project[2][
j];
407 corner_point[3][
j] = project[0][
j] + tmax*project[1][
j] + smin*project[2][
j];
410 for (cor = 0; cor <
CORNERS; cor++)
413 for (
j=0;
j<3;
j++) {
414 ray[
j] = -corner_point[cor][
j];
415 posECR[
j] = 7.0e6 * corner_point[cor][
j];
416 if (
fabs(ray[
j]) >= length)
417 length =
fabs(ray[
j]);
424 rtnfun = PGS_CSC_GrazingRay(
EARTH_MODEL, posECR, ray,
426 &missAlt, &slantRg, posNEAR, posSURF);
431 if (rtnfun != PGSCSC_W_HIT_EARTH)
434 "GEO_get_GRing_points.c, GEO_get_GRing_points");
441 if (rtnfun != PGS_S_SUCCESS)
444 "GEO_get_GRing_points.c, GEO_get_GRing_points");
457 *GRing_points = new_points;
459 return PGS_S_SUCCESS;