コード例 #1
0
ファイル: img.c プロジェクト: rlk/scmtiff
int img_simple_cylindrical(img *p, const double *v, double lon, double lat, double *t)
{
#if 0
    lon = tolon(lon - M_PI);
#endif

    t[0] =   p->line_projection_offset - p->map_resolution * (todeg(lat) - todeg( p->center_latitude)) - 1; // FIRST_PIXEL
    t[1] = p->sample_projection_offset + p->map_resolution * (todeg(lon) - todeg(p->center_longitude)) - 1; // FIRST_PIXEL

    return 1;
}
コード例 #2
0
ファイル: drivestrategy.cpp プロジェクト: ifsmirnov/tanks
void DriveStrategy::moveTo(ITank &tank, double x, double y, Action &action)
{
    double angle = tank.angleTo(x, y);
    //std::cerr << "angle = " << todeg(angle) << std::endl;
    if (fabs(todeg(angle)) < 15)
    {
        action.setLeft(1.0);
        action.setRight(1.0);
    }
    else if (fabs(angle) < M_PI / 2.0)
    {
        double left = std::max(1.0, tank.rearFactor() * 1.5);
        double right = -1.0;
        if (angle < 0)
            std::swap(left, right);
        action.setLeft(left);
        action.setRight(right);
    }
    else if (angle < 0)
    {
        action.setLeft(-1);
        action.setRight(tank.rearFactor());
    }
    else
    {
        action.setRight(-1);
        action.setLeft(tank.rearFactor());
    }
}
コード例 #3
0
ファイル: tamo_moon.c プロジェクト: tsupo/tamo
static double
phase( double pdate,
       double *pphase,      /* Illuminated fraction        */
       double *mage,        /* Age of moon in days         */
       double *dist,        /* Distance in kilometres      */
       double *angdia,      /* Angular diameter in degrees */
       double *sudist,      /* Distance to Sun             */
       double *suangdia )   /* Sun's angular diameter      */
{
    double  Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP,
            mEc, A4, lP, V, lPP, NP, y, x, Lambdamoon,
            MoonAge, MoonPhase,
            MoonDist, MoonDFrac, MoonAng,
            F, SunDist, SunAng;

    /* Calculation of the Sun's position */

    Day = pdate - epoch;                    /* Date within epoch */
    N = fixangle((360.0 / 365.2422) * Day); /* Mean anomaly of the Sun */
    M = fixangle(N + elonge - elongp);      /* Convert from perigee
                                               co-ordinates to epoch 1980.0 */
    Ec = kepler(M, eccent);                 /* Solve equation of Kepler */
    Ec = sqrt((1.0 + eccent) / (1.0 - eccent)) * tan(Ec / 2.0);
    Ec = 2.0 * todeg(atan(Ec));             /* True anomaly */
    Lambdasun = fixangle(Ec + elongp);      /* Sun's geocentric ecliptic
                                               longitude */
    /* Orbital distance factor */
    F = ((1.0 + eccent * cos(torad(Ec))) / (1.0 - eccent * eccent));
    SunDist = sunsmax / F;              /* Distance to Sun in km */
    SunAng = F * sunangsiz;             /* Sun's angular size in degrees */

    /* Calculation of the Moon's position */
    /* Moon's mean longitude */
    ml = fixangle(13.1763966 * Day + mmlong);

    /* Moon's mean anomaly */
    MM = fixangle(ml - 0.1114041 * Day - mmlongp);

    /* Moon's ascending node mean longitude */
    MN = fixangle(mlnode - 0.0529539 * Day);

    /* Evection */
    Ev = 1.2739 * sin(torad(2.0 * (ml - Lambdasun) - MM));

    /* Annual equation */
    Ae = 0.1858 * sin(torad(M));

    /* Correction term */
    A3 = 0.37 * sin(torad(M));

    /* Corrected anomaly */
    MmP = MM + Ev - Ae - A3;

    /* Correction for the equation of the centre */
    mEc = 6.2886 * sin(torad(MmP));

    /* Another correction term */
    A4 = 0.214 * sin(torad(2.0 * MmP));

    /* Corrected longitude */
    lP = ml + Ev + mEc - Ae + A4;

    /* Variation */
    V = 0.6583 * sin(torad(2.0 * (lP - Lambdasun)));

    /* True longitude */
    lPP = lP + V;

    /* Corrected longitude of the node */
    NP = MN - 0.16 * sin(torad(M));

    /* Y inclination coordinate */
    y = sin(torad(lPP - NP)) * cos(torad(minc));

    /* X inclination coordinate */
    x = cos(torad(lPP - NP));

    /* Ecliptic longitude */
    Lambdamoon = todeg(atan2(y, x));
    Lambdamoon += NP;

#if 0
    /* Ecliptic latitude */
    (void)todeg(asin(sin(torad(lPP - NP)) * sin(torad(minc))));
#endif

    /* Calculation of the phase of the Moon */
    /* Age of the Moon in degrees */
    MoonAge = lPP - Lambdasun;

    /* Phase of the Moon */
    MoonPhase = (1.0 - cos(torad(MoonAge))) / 2.0;

    /* Calculate distance of moon from the centre of the Earth */

    MoonDist = (msmax * (1.0 - mecc * mecc)) /
                   (1.0 + mecc * cos(torad(MmP + mEc)));

    /* Calculate Moon's angular diameter */

    MoonDFrac = MoonDist / msmax;
    MoonAng = mangsiz / MoonDFrac;

#if	0
    /* Calculate Moon's parallax */
    MoonPar = mparallax / MoonDFrac;
#endif
    *pphase   = MoonPhase;
    *mage     = synmonth * (fixangle(MoonAge) / 360.0);
    *dist     = MoonDist;
    *angdia   = MoonAng;
    *sudist   = SunDist;
    *suangdia = SunAng;
    return fixangle(MoonAge) / 360.0;
}
コード例 #4
0
 virtual void tolatlon(double l, double s, double& lat, double& lon) const
 {
     lon = torad(todeg(lonp) + (s - s0) / res);
     lat = torad(todeg(latp) - (l - l0) / res);
 }
コード例 #5
0
 virtual void torowcol(double lat, double lon, double& l, double& s) const
 {
     s = s0 + res * (todeg(lon) - todeg(lonp));
     l = l0 - res * (todeg(lat) - todeg(latp));
 }