-// moonpos.cxx (basically, this is a slightly modified version of the 'sunpos.cxx' file, adapted from XEarth)
-
+// moonpos.cxx (basically, this is a slightly modified version of the
+// 'sunpos.cxx' file, adapted from XEarth)
+//
// kirk johnson
// july 1993
//
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/ephemeris/ephemeris.hxx>
-#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
+#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/vector.hxx>
-#include <simgear/timing/fg_time.hxx>
-#include <Main/views.hxx>
+#include <Main/globals.hxx>
#include <Scenery/scenery.hxx>
+#include <Time/light.hxx>
#include "moonpos.hxx"
-// extern SolarSystem *solarSystem;
-extern FGEphemeris *ephem;
-
#undef E
* every ten minutes. (Comment added by Durk Talsma).
************************************************************************/
- ecliptic_to_equatorial( ephem->get_moon()->getLon(),
+ ecliptic_to_equatorial( globals->get_ephem()->get_moon()->getLon(),
0.0, &alpha, &delta );
tmp = alpha - (FG_2PI/24)*GST(ssue);
if (tmp < -FG_PI) {
/* lambda = moon_ecliptic_longitude(ssue); */
/* ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta); */
//ecliptic_to_equatorial (solarPosition.lonMoon, 0.0, &alpha, &delta);
- ecliptic_to_equatorial( ephem->get_moon()->getLon(),
- ephem->get_moon()->getLat(),
+ ecliptic_to_equatorial( globals->get_ephem()->get_moon()->getLon(),
+ globals->get_ephem()->get_moon()->getLat(),
&alpha, &delta );
// tmp = alpha - (FG_2PI/24)*GST(ssue);
// update the cur_time_params structure with the current moon position
void fgUpdateMoonPos( void ) {
fgLIGHT *l;
- FGTime *t;
- FGView *v;
- sgVec3 nup, nmoon, v0, surface_to_moon;
+ FGViewerRPH *v;
+ sgVec3 nup, nmoon, surface_to_moon;
Point3D p, rel_moonpos;
double dot, east_dot;
double moon_gd_lat, sl_radius;
l = &cur_light_params;
- t = FGTime::cur_time_params;
- v = ¤t_view;
+ SGTime *t = globals->get_time_params();
+ v = (FGViewerRPH *)globals->get_current_view();
FG_LOG( FG_EVENT, FG_INFO, " Updating Moon position" );
// fgMoonPosition(t->cur_time, &l->moon_lon, &moon_gd_lat);
fgMoonPositionGST(t->getGst(), &l->moon_lon, &moon_gd_lat);
- fgGeodToGeoc(moon_gd_lat, 0.0, &sl_radius, &l->moon_gc_lat);
+ sgGeodToGeoc(moon_gd_lat, 0.0, &sl_radius, &l->moon_gc_lat);
p = Point3D( l->moon_lon, l->moon_gc_lat, sl_radius );
- l->fg_moonpos = fgPolarToCart3d(p);
+ l->fg_moonpos = sgPolarToCart3d(p);
FG_LOG( FG_EVENT, FG_INFO, " t->cur_time = " << t->get_cur_time() );
FG_LOG( FG_EVENT, FG_INFO,
// << ","<< l->moon_vec[2] << endl;
// calculate the moon's relative angle to local up
- sgCopyVec3( nup, v->get_local_up() );
+ sgCopyVec3( nup, v->get_world_up() );
sgSetVec3( nmoon, l->fg_moonpos.x(), l->fg_moonpos.y(), l->fg_moonpos.z() );
sgNormalizeVec3(nup);
sgNormalizeVec3(nmoon);
<< l->moon_angle << endl;
// calculate vector to moon's position on the earth's surface
- rel_moonpos = l->fg_moonpos - (v->get_view_pos() + scenery.center);
+ Point3D vp( v->get_view_pos()[0],
+ v->get_view_pos()[1],
+ v->get_view_pos()[1] );
+ rel_moonpos = l->fg_moonpos - ( vp + scenery.center );
v->set_to_moon( rel_moonpos.x(), rel_moonpos.y(), rel_moonpos.z() );
// printf( "Vector to moon = %.2f %.2f %.2f\n",
// v->to_moon[0], v->to_moon[1], v->to_moon[2]);
- // make a vector to the current view position
- Point3D view_pos = v->get_view_pos();
- sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
// Given a vector from the view position to the point on the
// earth's surface the moon is directly over, map into onto the
// local plane representing "horizontal".
- sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v0,
+ sgmap_vec_onto_cur_surface_plane( v->get_world_up(), v->get_view_pos(),
v->get_to_moon(), surface_to_moon );
sgNormalizeVec3(surface_to_moon);
v->set_surface_to_moon( surface_to_moon[0], surface_to_moon[1],