~ubuntu-branches/ubuntu/warty/xplanet/warty

« back to all changes in this revision

Viewing changes to libsgp4sdp4/solar.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040824071400-2dr4qnjbjmm8z3ia
Tags: 1.0.6-1ubuntu1
Build-depend: libtiff4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Unit Solar
3
 
 *           Author:  Dr TS Kelso
4
 
 * Original Version:  1990 Jul 29
5
 
 * Current Revision:  1999 Nov 27
6
 
 *          Version:  1.30
7
 
 *        Copyright:  1990-1999, All Rights Reserved
8
 
 *
9
 
 *   Ported to C by: Neoklis Kyriazis  April 1 2001
10
 
 */
11
 
 
12
 
#include "sgp4sdp4.h"
13
 
 
14
 
/* Calculates solar position vector */
15
 
void
16
 
Calculate_Solar_Position(double time, vector_t *solar_vector)
17
 
{
18
 
  double mjd,year,T,M,L,e,C,O,Lsa,nu,R,eps;
19
 
 
20
 
  mjd = time - 2415020.0;
21
 
  year = 1900 + mjd/365.25;
22
 
  T = (mjd + Delta_ET(year)/secday)/36525.0;
23
 
  M = Radians(Modulus(358.47583 + Modulus(35999.04975*T,360.0)
24
 
                      - (0.000150 + 0.0000033*T)*Sqr(T),360.0));
25
 
  L = Radians(Modulus(279.69668 + Modulus(36000.76892*T,360.0)
26
 
                      + 0.0003025*Sqr(T),360.0));
27
 
  e = 0.01675104 - (0.0000418 + 0.000000126*T)*T;
28
 
  C = Radians((1.919460 - (0.004789 + 0.000014*T)*T)*sin(M)
29
 
              + (0.020094 - 0.000100*T)*sin(2*M) + 0.000293*sin(3*M));
30
 
  O = Radians(Modulus(259.18 - 1934.142*T,360.0));
31
 
  Lsa = Modulus(L + C - Radians(0.00569 - 0.00479*sin(O)),twopi);
32
 
  nu = Modulus(M + C,twopi);
33
 
  R = 1.0000002*(1 - Sqr(e))/(1 + e*cos(nu));
34
 
  eps = Radians(23.452294 - (0.0130125 + (0.00000164 -
35
 
                0.000000503*T)*T)*T + 0.00256*cos(O));
36
 
  R = AU*R;
37
 
  solar_vector->x = R*cos(Lsa);
38
 
  solar_vector->y = R*sin(Lsa)*cos(eps);
39
 
  solar_vector->z = R*sin(Lsa)*sin(eps);
40
 
  solar_vector->w = R;
41
 
} /*Procedure Calculate_Solar_Position*/
42
 
 
43
 
/*------------------------------------------------------------------*/
44
 
 
45
 
/* Calculates stellite's eclipse status and depth */
46
 
int
47
 
Sat_Eclipsed(vector_t *pos, vector_t *sol, double *depth)
48
 
{
49
 
  double sd_sun, sd_earth, delta;
50
 
  vector_t Rho, earth;
51
 
 
52
 
  /* Determine partial eclipse */
53
 
  sd_earth = ArcSin(xkmper/pos->w);
54
 
  Vec_Sub(sol,pos,&Rho);
55
 
  sd_sun = ArcSin(sr/Rho.w);
56
 
  Scalar_Multiply(-1,pos,&earth);
57
 
  delta = Angle(sol,&earth);
58
 
  *depth = sd_earth - sd_sun - delta;
59
 
  if( sd_earth < sd_sun )
60
 
    return( 0 );
61
 
  else
62
 
    if( *depth >= 0 )
63
 
      return( 1 );
64
 
    else
65
 
      return( 0 );
66
 
 
67
 
} /*Function Sat_Eclipsed*/
68
 
 
69
 
/*------------------------------------------------------------------*/