/* ** The HAE to HEEQ transformation is given by the matrix ** ** S2 = <theta0,Z>*<i,X>*<Omega,Z> ** ** where the rotation angle theta0 is the the longitude of the Sun's ** central meridian, i is the the inclination of the Sun's equator and ** Omega is the the ecliptic longitude of the ascending node of the Sun's ** equator. This transformation comprises a rotation in the plane of the ** ecliptic from the First Point of Aries to the ascending node of the ** solar equator, then a rotation from the plane of the ecliptic to the ** plane of the equator and finally a rotation in the plane of the solar ** equator from the ascending node to the central meridian. ** ** Implemented by Kristi Keller on 2/2/2004 */ void mat_S2(const double et, Mat mat) { Mat mat_tmp; double Omega = 73.6667+0.013958*(MJD(et)+3242)/365.25; double theta0 = atand(cosd(7.25) * tand(lambda0(et)-Omega)); double angle_1 = lambda0(et)-Omega; angle_1=fmod(angle_1,360.0); if (angle_1 < 0.0) angle_1+=360.0; theta0=fmod(theta0,360.0); if (theta0 < 0.0) theta0+=360.0; if (angle_1 < 180.0) { if (theta0 < 180.0) theta0+=180.0; } if (angle_1 > 180.0) { if (theta0 > 180.0) theta0-=180.0; } hapgood_matrix(theta0, Z, mat); hapgood_matrix(7.25, X, mat_tmp); mat_times_mat(mat, mat_tmp, mat); hapgood_matrix(Omega, Z, mat_tmp); mat_times_mat(mat, mat_tmp, mat); }
/* ** The GEI2000 to GEI transformation is given by the matrix ** ** P = <-zA,Z>*<thetaA,Y>*<-zetaA,Z> ** ** where the rotation angles zA, thetaA and zetaA are the precession ** angles. This transformation is a precession correction as described ** by Hapgood (1995). ** ** zA = 0.64062 T0 + 0.00030 T0^2 degrees ** thetaA = 0.55675 T0 - 0.00012 T0^2 degrees ** zetaA = 0.64062 T0 + 0.00008 T0^2 degrees */ void mat_P(const double et, Mat mat) { Mat mat_tmp; double t0 = T0(et); hapgood_matrix(-1.0*(0.64062 * t0 + 0.00030 * t0*t0), Z, mat); hapgood_matrix(0.55675 * t0 - 0.00012 * t0*t0, Y, mat_tmp); mat_times_mat(mat, mat_tmp, mat); hapgood_matrix(-1.0*(0.64062 * t0 + 0.00008 * t0*t0), Z, mat_tmp); mat_times_mat(mat, mat_tmp, mat); }
/* ** vec_Qe ** ** don't ask. */ void vec_Qe(double et, Vec Qe) { double lat = mag_lat(et); double lon = mag_lon(et); double cos_lat = cos(lat); double sin_lat = sin(lat); double cos_lon = cos(lon); double sin_lon = sin(lon); Mat mat_tmp, mat; Vec Qg; Qg[0] = cos_lat * cos_lon; Qg[1] = cos_lat * sin_lon; Qg[2] = sin_lat; /* printf("lat=%lf lon=%lf\n", 90.0 - lat, lon);*/ mat_T2(et, mat); mat_T1(et, mat_tmp); mat_transpose(mat_tmp, mat_tmp); mat_times_mat(mat, mat_tmp, mat); mat_times_vec(mat, Qg, Qe); }
Mat* create_look_at_mat(Vec* cam_pos, Vec* targ_pos, Vec* up) { Mat* p = create_translation_mat(-cam_pos->x, -cam_pos->y, -cam_pos->z); Vec* d = vec_minus_vec(targ_pos, cam_pos); Vec* f = normalize_vec(d); Vec* c1 = cross_vec(f, up); Vec* r = normalize_vec(c1); Vec* c2 = cross_vec(r, f); Vec* u = normalize_vec(c2); Mat* ori = identity_mat(); ori->m[0] = r->x; ori->m[4] = r->y; ori->m[8] = r->z; ori->m[1] = u->x; ori->m[5] = u->y; ori->m[9] = u->z; ori->m[2] = -f->x; ori->m[6] = -f->y; ori->m[10] = -f->z; Mat* ret = mat_times_mat(ori, p); delete_mat(p); delete_mat(ori); delete_vec(d); delete_vec(f); delete_vec(r); delete_vec(u); delete_vec(c1); delete_vec(c2); return ret; }
/* ** The GEO to MAG transformation is given by the matrix ** ** T5 = <lat-90,Y>*<long,Z> ** ** where the rotation angle lat is the latitude and angle long is the ** longitude of the geomagnetic pole (as defined by the axis of the ** dipole component of the geomagnetic field). This transformation is ** a rotation in the plane of the Earth's equator from the Greenwich ** meridian to the meridian containing the dipole axis, followed by ** a rotation in that meridian from the rotation axis to the dipole axis. */ void mat_T5(const double et, Mat mat) { Mat mat_tmp; hapgood_matrix((mag_lat(et)*RADIANS_TO_DEGREES) - 90.0, Y, mat); hapgood_matrix((mag_lon(et)*RADIANS_TO_DEGREES), Z, mat_tmp); mat_times_mat(mat, mat_tmp, mat); }
/* ** The GEI to GSE transformation is given by the matrix ** ** T2 = <lambdaO,Z>*<epsilon,X> ** ** where the rotation angle lambdaO is the Sun's ecliptic longitude and ** the angle epsilon is the obliquity of the ecliptic. This transformation ** is a rotation from the Earth's equator to the plane of the ecliptic ** followed by a rotation in the plane of the ecliptic from the First Point ** of Aries to the Earth-Sun direction. */ void mat_T2(const double et, Mat mat) { Mat mat_tmp; hapgood_matrix(lambda0(et), Z, mat); hapgood_matrix(epsilon(et), X, mat_tmp); mat_times_mat(mat, mat_tmp, mat); }