Пример #1
0
int
vis(double t, double slat, double slong, double q)
{
	double t0, t1, t2, d;

	d = t/86400 - .005375 + 3653;
	t0 = 6.238030674 + .01720196977*d;
	t2 = t0 + .0167253303*sin(t0);
	do {
		t1 = (t0 - t2 + .0167259152*sin(t2)) /
			(1 - .0167259152*cos(t2));
		t2 = t2 + t1;
	} while(fabs(t1) >= 1.e-4);
	t0 = 2*atan2(1.01686816*sin(t2/2), cos(t2/2));
	t0 = 4.926234925 + 8.214985538e-7*d + t0;
	t1 = 0.91744599 * sin(t0);
	t0 = atan2(t1, cos(t0));
	if(t0 < -pi/2)
		t0 = t0 + pipi;
	d = 4.88097876 + 6.30038809*d - t0;
	t0 = 0.43366079 * t1;
	t1 = pyth(t0);
	t2 = t1*cos(slat)*cos(d-slong) - t0*sin(slat);
	if(t2 > 0.46949322e-2) {
		if(0.46949322e-2*t2 + 0.999988979*pyth(t2) < q)
			return 0;
	}
	t2 = t1*cos(glat)*cos(d-wlong) - t0*sin(glat);
	if(t2 < .1)
		return 0;
	return 1;
}
Пример #2
0
void
satel(double time)
{
	int i;
	double amean, an, coc, csl, d, de, enom, eo;
	double pp, q, rdp, slong, ssl, t, tp;

	i = 500;
	el = -1;
	time = (time-25567.5) * 86400;
	t = (time - satl.time)/60;
	if(t < 0)
		return; /* too early for satelites */
	an = floor(t/satl.peri);
	while(an*satl.peri + an*an*satl.d1per/2. <= t) {
		an += 1;
		if(--i == 0)
			return;
	}
	while((tp = an*satl.peri + an*an*satl.d1per/2.) > t) {
		an -= 1;
		if(--i == 0)
			return;
	}
	amean = (t-tp)/(satl.peri+(an+.5)*satl.d1per);
	pp = satl.ppi+(an+amean)*satl.d1pp;
	amean *= pipi;
	eo = satl.e0+satl.deo*an;
	rdp = satl.semi/(1+eo);
	enom = amean+eo*sin(amean);
	do {
		de = (amean-enom+eo*sin(enom))/(1.0-eo*cos(enom));
		enom += de;
		if(--i == 0)
			return;
	} while(fabs(de) >= 1.0e-6);
	q = 3963.35*erad/(rdp*(1-eo*cos(enom))/(1-eo));
	d = pp + 2*atan2(sqrt((1+eo)/(1-eo))*sin(enom/2),cos(enom/2));
	slong = satl.pnni + t*satl.rot -
		atan2(satl.ct*sin(d), cos(d));
	ssl = satl.st*sin(d);
	csl = pyth(ssl);
	if(vis(time, atan2(ssl,csl), slong, q)) {
		coc = ssl*sin(glat) + csl*cos(glat)*cos(wlong-slong);
		el = atan2(coc-q, pyth(coc));
		el /= radian;
	}
}
Пример #3
0
void recalculate (double cx, double cy, double* xx, double* yy, int npoints, point_info_t* point_info, line_info_t* line_info) {
    int i;
    double ax, ay, bx, by;
    double dp, rl, px, py, sl, dl, ll, dx, dy, theta, l2;
    for (i = 0; i < npoints; i += 1) {
        point_info[i].dp = pyth(cx, cy, xx[i], yy[i]);
    }
    for (i = 0; i < (npoints - 1); i += 1) {
        ax = xx[i];
        ay = yy[i];
        bx = xx[i+1];
        by = yy[i+1];
        line_info[i].ll    = ll    = pyth(ax, ay, bx, by);
        line_info[i].l2    = l2    = ll * ll;
        line_info[i].dx    = dx    = bx - ax;
        line_info[i].dy    = dy    = by - ay;
        line_info[i].theta = theta = atan2(dy, dx);
        line_info[i].rl    = rl    = ((cx - ax) * (bx - ax) + (cy - ay) * (by - ay)) / l2;
        line_info[i].px    = px    = ax + rl * (bx - ax);
        line_info[i].py    = py    = ay + rl * (by - ay);
        line_info[i].sl    = sl    = ((ay - cy) * (bx - ax) - (ax - cx) * (by - ay)) / l2;
        line_info[i].dl    = dl    = fabs(sl) * ll;
    }
}
Пример #4
0
void
venus(void)
{
	double pturbl, pturbb, pturbr;
	double lograd;
	double dele, enom, vnom, nd, sl;
	double v0, t0, m0, j0, s0;
	double lsun, elong, ci, dlong;

/*
 *	here are the mean orbital elements
 */

	ecc = .00682069 - .00004774*capt + 0.091e-6*capt2;
	incl = 3.393631 + .0010058*capt - 0.97e-6*capt2;
	node = 75.779647 + .89985*capt + .00041*capt2;
	argp = 130.163833 + 1.408036*capt - .0009763*capt2;
	mrad = .7233316;
	anom = 212.603219 + 1.6021301540*eday + .00128605*capt2;
	motion = 1.6021687039;

/*
 *	mean anomalies of perturbing planets
 */

	v0 = 212.60 + 1.602130154*eday;
	t0 = 358.63  + .985608747*eday;
	m0 = 319.74 + 0.524032490*eday;
	j0 = 225.43 + .083090842*eday;
	s0 = 175.8  + .033459258*eday;

	v0 *= radian;
	t0 *= radian;
	m0 *= radian;
	j0 *= radian;
	s0 *= radian;

	incl *= radian;
	node *= radian;
	argp *= radian;
	anom = fmod(anom, 360.)*radian;

/*
 *	computation of long period terms affecting the mean anomaly
 */

	anom +=
		   (2.761-0.022*capt)*radsec*sin(
		  13.*t0 - 8.*v0 + 43.83*radian + 4.52*radian*capt)
		 + 0.268*radsec*cos(4.*m0 - 7.*t0 + 3.*v0)
		 + 0.019*radsec*sin(4.*m0 - 7.*t0 + 3.*v0)
		 - 0.208*radsec*sin(s0 + 1.4*radian*capt);

/*
 *	computation of elliptic orbit
 */

	enom = anom + ecc*sin(anom);
	do {
		dele = (anom - enom + ecc * sin(enom)) /
			(1 - ecc*cos(enom));
		enom += dele;
	} while(fabs(dele) > converge);
	vnom = 2*atan2(sqrt((1+ecc)/(1-ecc))*sin(enom/2),
		cos(enom/2));
	rad = mrad*(1 - ecc*cos(enom));

	lambda = vnom + argp;

/*
 *	perturbations in longitude
 */

	icosadd(venfp, vencp);
	pturbl = cosadd(4, v0, t0, m0, j0);
	pturbl *= radsec;

/*
 *	perturbations in latidude
 */

	pturbb = cosadd(3, v0, t0, j0);
	pturbb *= radsec;

/*
 *	perturbations in log radius vector
 */

	pturbr = cosadd(4, v0, t0, m0, j0);

/*
 *	reduction to the ecliptic
 */

	lambda += pturbl;
	nd = lambda - node;
	lambda = node + atan2(sin(nd)*cos(incl),cos(nd));

	sl = sin(incl)*sin(nd);
	beta = atan2(sl, pyth(sl)) + pturbb;

	lograd = pturbr*2.30258509;
	rad *= 1 + lograd;


	motion *= radian*mrad*mrad/(rad*rad);

/*
 *	computation of magnitude
 */

	lsun = 99.696678 + 0.9856473354*eday;
	lsun *= radian;
	elong = lambda - lsun;
	ci = (rad - cos(elong))/sqrt(1 + rad*rad - 2*rad*cos(elong));
	dlong = atan2(pyth(ci), ci)/radian;
	mag = -4 + .01322*dlong + .0000004247*dlong*dlong*dlong;

	semi = 8.41;

	helio();
	geo();
}
Пример #5
0
void
plut(void)
{
	double pturbl, pturbb, pturbr;
	double lograd;
	double dele, enom, vnom, nd, sl;

	double capj, capn, eye, comg, omg;
	double sb, su, cu, u, b, up;
	double sd, ca, sa;

	double cy;

	cy = (eday - elem[0]) / 36525.;		/* per julian century */

	mrad = elem[1] + elem[1+6]*cy;
	ecc = elem[2] + elem[2+6]*cy;

	cy = cy / 3600;				/* arcsec/deg per julian century */
	incl = elem[3] + elem[3+6]*cy;
	node = elem[4] + elem[4+6]*cy;
	argp = elem[5] + elem[5+6]*cy;

	anom = elem[6] + elem[6+6]*cy - argp;
	motion = elem[6+6] / 36525. / 3600;

	incl *= radian;
	node *= radian;
	argp *= radian;
	anom = fmod(anom,360.)*radian;

	enom = anom + ecc*sin(anom);
	do {
		dele = (anom - enom + ecc * sin(enom)) /
			(1. - ecc*cos(enom));
		enom += dele;
	} while(fabs(dele) > converge);
	vnom = 2.*atan2(sqrt((1.+ecc)/(1.-ecc))*sin(enom/2.),
		cos(enom/2.));
	rad = mrad*(1. - ecc*cos(enom));

	lambda = vnom + argp;
	pturbl = 0.;
	lambda += pturbl*radsec;
	pturbb = 0.;
	pturbr = 0.;

/*
 *	reduce to the ecliptic
 */

	nd = lambda - node;
	lambda = node + atan2(sin(nd)*cos(incl),cos(nd));

	sl = sin(incl)*sin(nd) + pturbb*radsec;
	beta = atan2(sl, pyth(sl));

	lograd = pturbr*2.30258509;
	rad *= 1. + lograd;


	lambda -= 1185.*radsec;
	beta -= 51.*radsec;

	motion *= radian*mrad*mrad/(rad*rad);
	semi = 83.33;

/*
 *	here begins the computation of magnitude
 *	first find the geocentric equatorial coordinates of Saturn
 */

	sd = rad*(cos(beta)*sin(lambda)*sin(obliq) +
		sin(beta)*cos(obliq));
	sa = rad*(cos(beta)*sin(lambda)*cos(obliq) -
		sin(beta)*sin(obliq));
	ca = rad*cos(beta)*cos(lambda);
	sd += zms;
	sa += yms;
	ca += xms;
	alpha = atan2(sa,ca);
	delta = atan2(sd,sqrt(sa*sa+ca*ca));

/*
 *	here are the necessary elements of Saturn's rings
 *	cf. Exp. Supp. p. 363ff.
 */

	capj = 6.9056 - 0.4322*capt;
	capn = 126.3615 + 3.9894*capt + 0.2403*capt2;
	eye = 28.0743 - 0.0128*capt;
	comg = 168.1179 + 1.3936*capt;
	omg = 42.9236 - 2.7390*capt - 0.2344*capt2;

	capj *= radian;
	capn *= radian;
	eye *= radian;
	comg *= radian;
	omg *= radian;

/*
 *	now find saturnicentric ring-plane coords of the earth
 */

	sb = sin(capj)*cos(delta)*sin(alpha-capn) -
		cos(capj)*sin(delta);
	su = cos(capj)*cos(delta)*sin(alpha-capn) +
		sin(capj)*sin(delta);
	cu = cos(delta)*cos(alpha-capn);
	u = atan2(su,cu);
	b = atan2(sb,sqrt(su*su+cu*cu));

/*
 *	and then the saturnicentric ring-plane coords of the sun
 */

	su = sin(eye)*sin(beta) +
		cos(eye)*cos(beta)*sin(lambda-comg);
	cu = cos(beta)*cos(lambda-comg);
	up = atan2(su,cu);

/*
 *	at last, the magnitude
 */


	sb = sin(b);
	mag = -8.68 +2.52*fabs(up+omg-u)-
		2.60*fabs(sb) + 1.25*(sb*sb);

	helio();
	geo();
}
Пример #6
0
void move_point_away (double* xp,
                      double* yp,
                      double minimum_distance,
                      double general_direction,
                      double* xx,
                      double* yy,
                      int npoints) {

    double distance = minimum_distance;
    minimum_distance = distance + 0.001; /* fudge factor */

    if (npoints < 1) {
        return;
    }
    if (npoints == 1) {
        double theta = atan2(yy[0] - *yp, xx[0] - *xp);
        if (pyth(*xp, *yp, xx[0], yy[0]) < minimum_distance) {
            *xp = xx[0] + distance * cos(theta);
            *yp = yy[0] + distance * sin(theta);
        }
        return;
    }

    int i;
    point_info_t* point_info = (point_info_t *) malloc(sizeof(point_info_t) * npoints);
    line_info_t*  line_info  = (line_info_t *)  malloc(sizeof(line_info_t)  * npoints);
    recalculate(*xp, *yp, xx, yy, npoints, point_info, line_info);

    double adx;
    double ady;
    double atheta;
start_over:
    for (i = 0; i < (npoints - 2); i += 1) {
        if ((line_info[i].dl < minimum_distance &&
                line_info[i+1].dl < minimum_distance &&
                line_info[i].rl >= 0 &&
                line_info[i].rl <= 1 &&
                line_info[i+1].rl >= 0 &&
                line_info[i+1].rl <= 1) ||
                point_info[i+1].dp < minimum_distance) {
            adx = line_info[i].dx / line_info[i].ll + line_info[i+1].dx / line_info[i+1].ll;
            ady = line_info[i].dy / line_info[i].ll + line_info[i+1].dy / line_info[i+1].ll;
            atheta = atan2(ady, adx);
            if (sin(atheta - general_direction) < 0) {
                *xp = xx[i+1] - distance * sin(atheta);
                *yp = yy[i+1] + distance * cos(atheta);
            }
            else {
                *xp = xx[i+1] + distance * sin(atheta);
                *yp = yy[i+1] - distance * cos(atheta);
            }
            recalculate(*xp, *yp, xx, yy, npoints, point_info, line_info);
        }
    }
    for (i = 0; i < (npoints - 1); i += 1) {
        if (line_info[i].dl < minimum_distance && line_info[i].rl >= 0 && line_info[i].rl <= 1) {
            if (sin(line_info[i].theta - general_direction) < 0) {
                *xp = line_info[i].px - distance * sin(line_info[i].theta);
                *yp = line_info[i].py + distance * cos(line_info[i].theta);
            }
            else {
                *xp = line_info[i].px + distance * sin(line_info[i].theta);
                *yp = line_info[i].py - distance * cos(line_info[i].theta);
            }
            recalculate(*xp, *yp, xx, yy, npoints, point_info, line_info);
        }
    }
    if (point_info[0].dp < minimum_distance) {
        if (sin(line_info[0].theta - general_direction) < 0) {
            *xp = xx[0] - distance * sin(line_info[0].theta);
            *yp = yy[0] + distance * cos(line_info[0].theta);
        }
        else {
            *xp = xx[0] + distance * sin(line_info[0].theta);
            *yp = yy[0] - distance * cos(line_info[0].theta);
        }
        recalculate(*xp, *yp, xx, yy, npoints, point_info, line_info);
    }
    else if (point_info[npoints - 1].dp < minimum_distance) {
        if (sin(line_info[npoints - 2].theta - general_direction) < 0) {
            *xp = xx[npoints-1] - distance * sin(line_info[npoints-2].theta);
            *yp = yy[npoints-1] + distance * cos(line_info[npoints-2].theta);
        }
        else {
            *xp = xx[npoints-1] + distance * sin(line_info[npoints-2].theta);
            *yp = yy[npoints-1] - distance * cos(line_info[npoints-2].theta);
        }
        recalculate(*xp, *yp, xx, yy, npoints, point_info, line_info);
    }

    free(point_info);
    free(line_info);
}
Пример #7
0
void
jup(void)
{
	double pturbl, pturbb, pturbr;
	double lograd;
	double dele, enom, vnom, nd, sl;


	ecc = .0483376 + 163.e-6*capt;
	incl = 1.308660 - .0055*capt;
	node = 99.43785 + 1.011*capt;
	argp = 12.71165 + 1.611*capt;
	mrad = 5.202803;
	anom = 225.22165 + .0830912*eday - .0484*capt;
	motion = 299.1284/3600.;

	incl *= radian;
	node *= radian;
	argp *= radian;
	anom = fmod(anom,360.)*radian;

	enom = anom + ecc*sin(anom);
	do {
		dele = (anom - enom + ecc * sin(enom)) /
			(1. - ecc*cos(enom));
		enom += dele;
	} while(fabs(dele) > converge);
	vnom = 2.*atan2(sqrt((1.+ecc)/(1.-ecc))*sin(enom/2.),
		cos(enom/2.));
	rad = mrad*(1. - ecc*cos(enom));

	lambda = vnom + argp;

	pturbl = 0.;

	lambda += pturbl*radsec;

	pturbb = 0.;

	pturbr = 0.;

/*
 *	reduce to the ecliptic
 */

	nd = lambda - node;
	lambda = node + atan2(sin(nd)*cos(incl),cos(nd));

	sl = sin(incl)*sin(nd) + pturbb*radsec;
	beta = atan2(sl, pyth(sl));

	lograd = pturbr*2.30258509;
	rad *= 1. + lograd;


	lambda += 555.*radsec;
	beta -= 51.*radsec;
	motion *= radian*mrad*mrad/(rad*rad);
	semi = 98.47;

	mag = -8.93;
	helio();
	geo();
}