Ignore:
Timestamp:
Jun 15, 2004, 6:54:12 PM (21 years ago)
Author:
cmv
Message:

nouvelle version de xephem/libastro (3.6) cmv 15/6/04

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/XephemAstroLib/riset_cir.c

    r1719 r2551  
    33#include <stdio.h>
    44#include <math.h>
    5 #if defined(__STDC__)
    65#include <stdlib.h>
    76#include <string.h>
    8 #endif
    9 
    10 #include "P_.h"
     7
    118#include "astro.h"
    12 #include "circum.h"
    139
    1410#define TMACC   (10./3600./24.0)        /* convergence accuracy, days */
    1511
    16 static void e_riset_cir P_((Now *np, Obj *op, double dis, RiseSet *rp));
    17 static int find_0alt P_((double dt, double dis, Now *np, Obj *op));
    18 static int find_transit P_((double dt, Now *np, Obj *op));
    19 static int find_max P_((Now *np, Obj *op, double tr, double ts, double *tp,
    20     double *alp));
     12static void e_riset_cir (Now *np, Obj *op, double dis, RiseSet *rp);
     13static int find_0alt (double dt, double dis, Now *np, Obj *op);
     14static int find_transit (double dt, Now *np, Obj *op);
     15static int find_max (Now *np, Obj *op, double tr, double ts, double *tp,
     16    double *alp);
    2117
    2218/* find where and when an object, op, will rise and set and
     
    2622 */
    2723void
    28 riset_cir (np, op, dis, rp)
    29 Now *np;
    30 Obj *op;
    31 double dis;
    32 RiseSet *rp;
     24riset_cir (Now *np, Obj *op, double dis, RiseSet *rp)
    3325{
    3426        double mjdn;    /* mjd of local noon */
     
    6456        /* first approximation is to find rise/set times of a fixed object
    6557         * at the current epoch in its position at local noon.
    66          * N.B. add typical refraction for initial go/no-go test. if it
    67          *   passes, real code does refraction rigorously.
     58         * N.B. add typical refraction if dis is above horizon for initial
     59         *   go/no-go test. if it passes, real code does refraction rigorously.
    6860         */
    6961        n.n_mjd = mjdn;
     
    7365        }
    7466        ran = o.s_gaera;
    75         riset (o.s_gaera, o.s_gaedec, lat, dis+.01, &lr, &ls, &ar, &as, &rss);
     67        riset (o.s_gaera, o.s_gaedec, lat, dis+(dis>.01 ? 0 : .01), &lr, &ls,
     68                                                                &ar, &as, &rss);
    7669        switch (rss) {
    7770        case  0:  break;
     
    133126 */
    134127void
    135 twilight_cir (np, dis, dawn, dusk, status)
    136 Now *np;
    137 double dis;
    138 double *dawn, *dusk;
    139 int *status;
     128twilight_cir (Now *np, double dis, double *dawn, double *dusk, int *status)
    140129{
    141130        RiseSet rs;
    142131        Obj o;
    143132
     133        memset (&o, 0, sizeof(o));
    144134        o.o_type = PLANET;
    145         o.pl.pl_code = SUN;
     135        o.pl_code = SUN;
    146136        (void) strcpy (o.o_name, "Sun");
    147137        riset_cir (np, &o, dis, &rs);
     
    160150 */
    161151static void
    162 e_riset_cir (np, op, dis, rp)
    163 Now *np;
    164 Obj *op;
    165 double dis;
    166 RiseSet *rp;
     152e_riset_cir (Now *np, Obj *op, double dis, RiseSet *rp)
    167153{
    168154#define DEGSTEP 5               /* time step is about this many degrees */
     
    272258 */
    273259static int
    274 find_0alt (dt, dis, np, op)
    275 double dt;      /* hours from noon to first guess at event */
    276 double dis;     /* horizon displacement, rads */
    277 Now *np;        /* working Now -- starts with mjd is noon, returns as answer */
    278 Obj *op;        /* working object -- returns as answer */
     260find_0alt (
     261double dt,      /* hours from noon to first guess at event */
     262double dis,     /* horizon displacement, rads */
     263Now *np,        /* working Now -- starts with mjd is noon, returns as answer */
     264Obj *op)        /* working object -- returns as answer */
    279265{
    280266#define MAXPASSES       20              /* max iterations to try */
     
    286272
    287273        /* insure initial guess is today -- if not, move by 24 hours */
    288         if (dt < -12.0)
    289             dt += 24.0;
    290         if (dt > 12.0)
    291             dt -= 24.0;
     274        if (dt < -12.0 && !find_0alt (dt+24, dis, np, op))
     275            return (0);
     276        mjd = mjdn;
     277        if (dt > 12.0 && !find_0alt (dt-24, dis, np, op))
     278            return (0);
     279        mjd = mjdn;
    292280       
    293281        /* convert dt to days for remainder of algorithm */
     
    325313 */
    326314static int
    327 find_transit (dt, np, op)
    328 double dt;
    329 Now *np;
    330 Obj *op;
     315find_transit (double dt, Now *np, Obj *op)
    331316{
    332317#define MAXLOOPS        10
     
    370355 */
    371356static int
    372 find_max (np, op, tr, ts, tp, alp)
    373 Now *np;
    374 Obj *op;
    375 double tr, ts;          /* times of rise and set */
    376 double *tp, *alp;       /* time of max altitude, and that altitude */
     357find_max (
     358Now *np,
     359Obj *op,
     360double tr, double ts,           /* times of rise and set */
     361double *tp, double *alp)        /* time of max altitude, and that altitude */
    377362{
    378363        mjd = (ts + tr)/2;
     
    385370
    386371/* For RCS Only -- Do Not Edit */
    387 static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: riset_cir.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
     372static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: riset_cir.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Note: See TracChangeset for help on using the changeset viewer.