Exemplo n.º 1
0
Arquivo: fk524.c Projeto: phn/pytpm
V6
fk524(V6 v)
{
    v = m6v6(M, v);

    /* restore e-terms */
#ifdef ETERMS
    {
        double m;		/* modulus of position vector */
        V3 s0;
        V3 s1, s1dot;
        V3 r0, r0dot;
        V3 r1, r1dot;

        /* cache the modulus */
        m = v6mod(v);

        /* convert the state vector back to a unit vector */
        v6GetPos(v) = v3scale(v6GetPos(v), 1/m);
        v6GetVel(v) = v3scale(v6GetVel(v), CB/(m*as2r(1)));

        /* now proceed with the standard treatment */
        r1 = v6GetPos(v);
        r1dot = v6GetVel(v);

        s1 = v3unit(r1);

        s0 = s1;
        r0 = v3sum(s1, v3diff(A, v3scale(s0, v3dot(s0, A))));
#ifdef ETERMS_ITERATE
        s0 = v3unit(r0);
        r0 = v3sum(s1, v3diff(A, v3scale(s0, v3dot(s0, A))));
#endif
        v6SetPos(v, r0);

#ifdef ETERMS_VEL
        s1dot = v3scale(r1dot, 1/v3mod(r1));
        r0dot = v3sum(s1dot, v3diff(Adot, v3scale(s0, v3dot(s0, Adot))));
        v6SetVel(v, r0dot);
#endif

        /* convert the unit vector back into a state vector */
        v6GetPos(v) = v3scale(v6GetPos(v), m);
        v6GetVel(v) = v3scale(v6GetVel(v), (m*as2r(1))/CB);
    }
#endif

    return(v);
}
Exemplo n.º 2
0
V6
ldeflect(V6 s, V6 e, int flag)
{
    double cprime;
    double g1;
    double g2;
    V3 ehat;
    V3 p;
    V3 qhat;
    V3 x;	/* the deflection vector */
    V3 x1;	/* scratch */
    V3 x2;	/* scratch */

    p = v6GetPos(s);

    {
	V6 v6;
	v6 = v6sum(e, s);
	qhat = v3unit(v6GetPos(v6));
    }
    ehat = v3unit(v6GetPos(e));

    cprime = 86400.0 * (IAU_C / IAU_AU);
    g1 = (2.0 * IAU_K * IAU_K) / (cprime * cprime * v6mod(e));
    g2 = 1 + v3dot(qhat, ehat);

    /* limit the value of g2 as Patrick Wallace does:
    ** clip it at 1.0e-5 radians (~922 arcseconds)
    */
    if (g2 < 1.0e-5) {
	g2 = 1.0e-5;
    }

    x1 = v3scale(ehat, v3dot(p, qhat));
    x2 = v3scale(qhat, v3dot(p, ehat));
    x = v3scale(v3diff(x1, x2), g1/g2);

    if (flag > 0) {
	p = v3sum(p, x);
    } else if (flag < 0) {
	p = v3diff(p, x);
    }

    v6SetPos(s, p);

    return(s);
}