source: trunk/MagicSoft/slalib/earth.c@ 9488

Last change on this file since 9488 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaEarth ( int iy, int id, float fd, float pv[6] )
4/*
5** - - - - - - - - -
6** s l a E a r t h
7** - - - - - - - - -
8**
9** Approximate heliocentric position and velocity of the Earth.
10**
11** (single precision)
12**
13** Given:
14** iy int year
15** id int day in year (1 = Jan 1st)
16** fd float fraction of day
17**
18** Returned:
19** pv float[6] Earth position & velocity vector
20**
21** Notes:
22**
23** 1 The date and time is TDB (loosely ET) in a Julian calendar
24** which has been aligned to the ordinary Gregorian
25** calendar for the interval 1900 March 1 to 2100 February 28.
26** The year and day can be obtained by calling slaCalyd or
27** slaClyd.
28**
29** 2 The Earth heliocentric 6-vector is mean equator and equinox
30** of date. Position part, PV(1-3), is in AU; velocity part,
31** PV(4-6), is in AU/sec.
32**
33** 3 Max/RMS errors 1950-2050:
34** 13/5 E-5 AU = 19200/7600 km in position
35** 47/26 E-10 AU/s = 0.0070/0.0039 km/s in speed
36**
37** 4 More precise results are obtainable with the routine slaEvp.
38**
39** Defined in slamac.h: D2PI, dmod
40**
41** Last revision: 25 April 1996
42**
43** Copyright P.T.Wallace. All rights reserved.
44*/
45
46#define SPEED 1.9913e-7f /* Mean orbital speed of Earth, AU/s */
47#define REMB 3.12e-5f /* Mean Earth:EMB distance, AU */
48#define SEMB 8.31e-11f /* Mean Earth:EMB speed, AU/s */
49
50{
51 float yi, yf, t, elm, gam, em, elt, eps0,
52 e, esq, v, r, elmm, coselt, sineps, coseps, w1, w2, selmm, celmm;
53 int iy4;
54
55/* Whole years & fraction of year, and years since J1900.0 */
56 yi = (float) ( iy - 1900 );
57 iy4 = iy >= 0 ? iy % 4 : 3 - ( - iy - 1 ) % 4;
58 yf = ( (float) ( 4 * ( id - 1 / ( iy4 + 1 ) )
59 - iy4 - 2 ) + 4.0f * fd ) / 1461.0f;
60 t = yi + yf;
61
62/* Geometric mean longitude of Sun */
63/* (cf 4.881627938+6.283319509911*t mod 2pi) */
64 elm = (float) dmod ( 4.881628
65 + D2PI * ( (double) yf ) + 0.00013420 * ( (double) t ),
66 D2PI );
67
68/* Mean longitude of perihelion */
69 gam = 4.908230f + 3.0005e-4f * t;
70
71/* Mean anomaly */
72 em = elm - gam;
73
74/* Mean obliquity */
75 eps0 = 0.40931975f - 2.27e-6f * t;
76
77/* Eccentricity */
78 e = 0.016751f - 4.2e-7f * t;
79 esq = (float) ( e * e );
80
81/* True anomaly */
82 v = em + 2.0f * e * (float) sin ( (double) em )
83 + 1.25f * esq * (float) sin ( 2.0 * (double) em );
84
85/* True ecliptic longitude */
86 elt = v + gam;
87
88/* True distance */
89 r = ( 1.0f - esq ) / ( 1.0f + e * (float) cos ( (double) v ) );
90
91/* Moon's mean longitude */
92 elmm = (float) dmod ( ( 4.72 + 83.9971 * ( (double) t ) ), D2PI );
93
94/* Useful functions */
95 coselt = (float) cos ( (double) elt );
96 sineps = (float) sin ( (double) eps0 );
97 coseps = (float) cos ( (double) eps0 );
98 w1 = -r * (float) sin ( (double) elt );
99 w2 = -SPEED * ( coselt + e * (float) cos ( (double) gam ) );
100 selmm = (float) sin ( (double) elmm );
101 celmm = (float) cos ( (double) elmm );
102
103/* Earth position and velocity */
104 pv[0] = - r * coselt - REMB * celmm;
105 pv[1] = ( w1 - REMB * selmm ) * coseps;
106 pv[2] = w1 * sineps;
107 pv[3] = SPEED * ( (float) sin ( (double) elt ) +
108 e * (float) sin ( (double) gam ) ) + SEMB * selmm;
109 pv[4] = ( w2 - SEMB * celmm ) * coseps;
110 pv[5] = w2 * sineps;
111}
Note: See TracBrowser for help on using the repository browser.