/* ** 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); }
/* ** Hapgood defines a transformation between GSE and HEE in his 1992 ** paper (section 6), but this part isn't online. ** ** The gist of it is, we rotate 180 degrees about Z, and then translate ** along X. ** ** But we also need to add "R", a constant vector defined by ** ** R = [ Rsun, 0, 0 ] ** ** where ** ** r0 (1 - e^2) ** Rsun = ------------ ** 1 + e cos(v) ** ** r0 = 1.495985E8 km mean distance of the Sun from Earth. ** ** e = 0.016709 - 0.0000418T0 eccentricity of the Sun's apparent ** orbit around the Earth. ** ** w = 282.94 + 1.72 T0 longitude of perigee of that orbit ** ** v = lambda0 - w (see lambda0 above) ** ** ** Implemented by Ed Santiago, Updated by Kristi Keller */ int gse_twixt_hee(const double et, Vec v_in, Vec v_out, Direction direction) { Mat mat; double r0,e, w,v, Rsun; hapgood_matrix(180, Z, mat); /* ** Note that there's no transposition here if the direction is "back"; ** the operation works identically in both directions. */ mat_times_vec(mat, v_in, v_out); /* Translate the X axis about the earth-sun distance */ r0 = (double)1.495985e8; e = 0.016709 - 0.0000418*T0(et); w = 282.94 + 1.72*T0(et); v = lambda0(et) - w; Rsun = r0*(1-e*e)/(1.+e*cosd(v)); /* v_out[0] += (double)1.5e8; */ v_out[0] += Rsun; return 0; }
int main(int argc, char* argv[]) { // "Sleep": 3675000 pLambda0 lambda0 = (pLambda0)GetProcAddressByHash(L"kernel32.dll", 3675000); lambda0(10000); return 0; }
/* ** 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); }
RcppExport SEXP nsem3b(SEXP data, SEXP theta, SEXP Sigma, SEXP modelpar, SEXP control ) { // srand ( time(NULL) ); /* initialize random seed: */ Rcpp::NumericVector Theta(theta); Rcpp::NumericMatrix D(data); unsigned nobs = D.nrow(), k = D.ncol(); mat Data(D.begin(), nobs, k, false); // Avoid copying Rcpp::NumericMatrix V(Sigma); mat S(V.begin(), V.nrow(), V.ncol()); S(0,0) = 1; mat iS = inv(S); double detS = det(S); Rcpp::List Modelpar(modelpar); // Rcpp::IntegerVector _nlatent = Modelpar["nlatent"]; unsigned nlatent = _nlatent[0]; Rcpp::IntegerVector _ny0 = Modelpar["nvar0"]; unsigned ny0 = _ny0[0]; Rcpp::IntegerVector _ny1 = Modelpar["nvar1"]; unsigned ny1 = _ny1[0]; Rcpp::IntegerVector _ny2 = Modelpar["nvar2"]; unsigned ny2 = _ny2[0]; Rcpp::IntegerVector _npred0 = Modelpar["npred0"]; unsigned npred0 = _npred0[0]; Rcpp::IntegerVector _npred1 = Modelpar["npred1"]; unsigned npred1 = _npred1[0]; Rcpp::IntegerVector _npred2 = Modelpar["npred2"]; unsigned npred2 = _npred2[0]; Rcpp::List Control(control); Rcpp::NumericVector _lambda = Control["lambda"]; double lambda = _lambda[0]; Rcpp::NumericVector _niter = Control["niter"]; double niter = _niter[0]; Rcpp::NumericVector _Dtol = Control["Dtol"]; double Dtol = _Dtol[0]; rowvec mu0(ny0), lambda0(ny0); rowvec mu1(ny1), lambda1(ny1); rowvec mu2(ny2), lambda2(ny2); rowvec beta0(npred0); rowvec beta1(npred1); rowvec beta2(npred2); rowvec gamma(2); rowvec gamma2(2); unsigned pos=0; for (unsigned i=0; i<ny0; i++) { mu0(i) = Theta[pos]; pos++; } for (unsigned i=0; i<ny1; i++) { mu1(i) = Theta[pos]; pos++; } for (unsigned i=0; i<ny2; i++) { mu2(i) = Theta[pos]; pos++; } for (unsigned i=0; i<ny0; i++) { lambda0(i) = Theta[pos]; pos++; } lambda1(0) = 1; for (unsigned i=1; i<ny1; i++) { lambda1(i) = Theta[pos]; pos++; } lambda2(0) = 1; for (unsigned i=1; i<ny2; i++) { lambda2(i) = Theta[pos]; pos++; } for (unsigned i=0; i<npred0; i++) { beta0(i) = Theta[pos]; pos++; } for (unsigned i=0; i<npred1; i++) { beta1(i) = Theta[pos]; pos++; } for (unsigned i=0; i<npred2; i++) { beta2(i) = Theta[pos]; pos++; } gamma(0) = Theta[pos]; gamma(1) = Theta[pos+1]; gamma2(0) = Theta[pos+2]; gamma2(1) = Theta[pos+3]; // cerr << "mu0=" << mu0 << endl; // cerr << "mu1=" << mu1 << endl; // cerr << "mu2=" << mu2 << endl; // cerr << "lambda0=" << lambda0 << endl; // cerr << "lambda1=" << lambda1 << endl; // cerr << "lambda2=" << lambda2 << endl; // cerr << "beta0=" << beta0 << endl; // cerr << "beta1=" << beta1 << endl; // cerr << "beta2=" << beta2 << endl; // cerr << "gamma=" << gamma << endl; // cerr << "gamma2=" << gamma2 << endl; mat lap(nobs,4); for (unsigned i=0; i<nobs; i++) { rowvec newlap = laNRb(Data.row(i), iS, detS, mu0, mu1, mu2, lambda0, lambda1, lambda2, beta0,beta1, beta2, gamma, gamma2, Dtol,niter,lambda); lap.row(i) = newlap; } List res; res["indiv"] = lap; res["logLik"] = sum(lap.col(0)) + (3-V.nrow())*log(2.0*datum::pi)*nobs/2; res["norm0"] = (3-V.nrow())*log(2*datum::pi)/2; return res; }
static double refmap_tetra_f2(double x, double y, double z) { return lambda0(x, y, z); }
/* ** The HAE to HEE transformation is given by the matrix ** ** S1 = <lambdaO + 180,Z> ** ** where the rotation angle lambdaO is the Sun's ecliptic longitude. ** This transformation is a rotation in the plane of the ecliptic from ** the First Point of Aries to the Sun-Earth direction. */ void mat_S1(const double et, Mat mat) { hapgood_matrix(lambda0(et) + 180.0, Z, mat); }