1 /**************************************************************************
4 * Written 1997 by Durk Talsma, started October, 1997. For the flight gear
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * (Log is kept at end of this file)
23 **************************************************************************/
26 #include "../Time/fg_time.h"
29 struct SunPos fgCalcSunPos(struct OrbElements params)
37 /* calculate the eccentric anomaly */
38 EccAnom = fgCalcEccAnom(params.M, params.e);
40 /* calculate the Suns distance (r) and its true anomaly (v) */
41 xv = cos(EccAnom) - params.e;
42 yv = sqrt(1.0 - params.e*params.e) * sin(EccAnom);
44 r = sqrt(xv*xv + yv*yv);
46 /* calculate the the Suns true longitude (lonsun) */
47 lonSun = v + params.w;
49 /* convert true longitude and distance to ecliptic rectangular geocentric
50 coordinates (xs, ys) */
51 solarPosition.xs = r * cos(lonSun);
52 solarPosition.ys = r * sin(lonSun);
58 /* Revision 1.1 1997/10/25 03:16:11 curt
59 /* Initial revision of code contributed by Durk Talsma.