Compare commits

...

12 Commits

Author SHA1 Message Date
curt
a1c59071a1 Changes by David Megginson. 2000-05-16 16:21:08 +00:00
curt
13af443057 cygwin32 fix for gdbm 2000-04-27 01:28:22 +00:00
curt
b8e2b0d0f9 Fixes for cygwin32 builds. 2000-04-27 01:26:36 +00:00
curt
53cd776bf6 Tweaks. 2000-03-30 00:48:38 +00:00
curt
180bba8767 Updated. 2000-03-29 21:28:14 +00:00
curt
377cf1662e For building redhat packages. 2000-03-29 00:00:46 +00:00
curt
420c747551 Ed Williams: Added some bulletproofing at the poles. 2000-03-28 22:08:31 +00:00
curt
7c5b4a87f2 Added gdbm 2000-03-28 22:06:34 +00:00
curt
7ea241b412 Added gdbm to SimGear. Many systems will already have gdbm installed so
it is only built if it doesn't already exist on the user's platform.
gdbm is a set of database routines that use extendible hashing and works
similar to the standard UNIX dbm routines.  This guarantees the availability
of gdbm to any application that uses SimGear.
2000-03-28 21:37:36 +00:00
curt
1547d4ee2f RedHat package building changes contributed by Habibie <habibie@MailandNews.com> 2000-03-28 19:49:07 +00:00
curt
3dde4113e7 Optimizations by Norman Vine:
Classic space vs time seemed worth it in that we get a ~3 fold speedup
  for ~5% space increase here.  Also pow() is an expensive Fortran to C
  translation in just about all the old government code I see :))
2000-03-28 15:20:20 +00:00
curt
205e6ef18f Bump up version # 2000-03-28 15:19:28 +00:00
16 changed files with 358 additions and 440 deletions

View File

@@ -1,6 +1,14 @@
EXTRA_DIST = mksymlinks.sh acsite.m4 acconfig.h
EXTRA_DIST = mksymlinks.sh acsite.m4 acconfig.h
SUBDIRS = simgear
#
# Rule to build RPM distribution package
#
rpm: dist
cp $(PACKAGE)-$(VERSION).tar.gz /usr/src/packages/SOURCES
rpm -ba @PACKAGE@.spec
dist-hook:
tar cf - simgear/metar | (cd $(distdir); tar xvf -)
SUBDIRS = simgear

12
NEWS
View File

@@ -1,3 +1,15 @@
New in 0.0.7
* March 29, 2000
* Added support for RedHat package building contributed by Habibie
<habibie@MailandNews.com>
* Added gdbm to SimGear. Many systems will already have gdbm installed so
it is only built if it doesn't already exist on the user's platform.
gdbm is a set of database routines that use extendible hashing and works
similar to the standard UNIX dbm routines. This guarantees the availability
of gdbm to any application that uses SimGear.
* Optimizations and bullet proofing of magnetic variation code by Norman
Vine and Ed Williams
New in 0.0.6
* March 27, 2000
* Added Nima World Magnetic Model 2000 contributed by Ed Williams

76
SimGear.spec.in Normal file
View File

@@ -0,0 +1,76 @@
%define ver @VERSION@
%define rel 1
%define prefix /usr
Summary: Simulator Construction Gear.
Name: @PACKAGE@
Version: %ver
Release: %rel
Copyright: LGPL
Group: Libraries/Graphics
Source: %{name}-%{version}.tar.gz
#URL:
BuildRoot: /tmp/%{name}-%{version}-%{rel}-root
Packager: Fill In As You Wish
Docdir: %{prefix}/doc
%description
This package contains a tools and libraries useful for constructing
simulation and visualization applications such as FlightGear or TerraGear.
Authors:
N/A
%prep
%setup -n %{name}-%{version}
%build
# Needed for snapshot releases.
if [ ! -f configure ]; then
CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix
else
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix
fi
if [ "$SMP" != "" ]; then
JSMP = '"MAKE=make -k -j $SMP"'
fi
make ${JSMP};
%install
[ -d ${RPM_BUILD_ROOT} ] && rm -rf ${RPM_BUILD_ROOT}
make prefix=${RPM_BUILD_ROOT}%{prefix} install
#
# Generating file lists and store them in file-lists
# Starting with the directory listings
#
find ${RPM_BUILD_ROOT}%{prefix}/{bin,include,lib} -type d | sed "s#^${RPM_BUILD_ROOT}#\%attr (-\,root\,root) \%dir #" > file-lists
%{?ETCDR:find ${RPM_BUILD_ROOT}%{!?SYSCF:%{prefix}}/etc -type d | sed "s#^${RPM_BUILD_ROOT}#\%attr (-\,root\,root) \%dir #" >> file-lists}
#
# Then, the file listings
#
echo "%defattr (-, root, root)" >> file-lists
%{?ETCDR:find ${RPM_BUILD_ROOT}%{!?SYSCF:%{prefix}}/etc/%{name}.conf -type f | sed -e "s#^${RPM_BUILD_ROOT}#%config #g" >> file-lists}
find ${RPM_BUILD_ROOT}%{prefix} -type f | sed -e "s#^${RPM_BUILD_ROOT}##g" >> file-lists
%clean
(cd ..; rm -rf %{name}-%{version} ${RPM_BUILD_ROOT})
%files -f file-lists
%defattr (-, root, root)
%doc AUTHORS
%doc COPYING
%doc ChangeLog
%doc INSTALL
%doc NEWS
%doc README
%doc %{name}.spec.in

View File

@@ -181,6 +181,9 @@
/* Define if you have the wait3 system call. */
#undef HAVE_WAIT3
/* Define if you have gdbm installed system wide. */
#undef HAVE_GDBM
/* Define if you have zlib installed system wide. */
#undef HAVE_ZLIB

View File

@@ -6,7 +6,7 @@ dnl $Id$
AC_INIT(simgear/bucket/newbucket.cxx)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.0.6)
AM_INIT_AUTOMAKE(SimGear, 0.0.8)
dnl Checks for programs.
AC_PROG_MAKE_SET
@@ -24,6 +24,10 @@ else
fi
dnl Run configure in the gdbm subdir
dnl AC_CONFIG_SUBDIRS( simgear/gdbm )
dnl Specify if we want logging (testing build) or not (release build)
# set logging default value
# with_logging=yes
@@ -196,6 +200,15 @@ if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
exit
fi
dnl Check for system installed gdbm
AC_CHECK_HEADER(gdbm.h)
if test "x$ac_cv_header_gdbm_h" = "xyes"; then
AC_DEFINE( HAVE_GDBM )
else
echo "no gdbm found, configuring and building."
fi
AM_CONDITIONAL(HAVE_GDBM, test "x$ac_cv_header_gdbm_h" = "xyes" )
dnl Check for system installed zlib
AC_CHECK_HEADER(zlib.h)
if test "x$ac_cv_header_zlib_h" = "xyes"; then
@@ -227,10 +240,12 @@ AM_CONFIG_HEADER(simgear/config.h)
AC_OUTPUT( \
Makefile \
SimGear.spec \
simgear/Makefile \
simgear/version.h \
simgear/bucket/Makefile \
simgear/debug/Makefile \
simgear/gdbm/Makefile \
simgear/magvar/Makefile \
simgear/math/Makefile \
simgear/misc/Makefile \
@@ -240,7 +255,11 @@ AC_OUTPUT( \
simgear/zlib/Makefile \
)
# AC_OUTPUT_COMMANDS([./mksymlinks.sh])
AC_OUTPUT_COMMANDS([
if test "x$ac_cv_header_windows_h" = "xyes" ; then
cp simgear/gdbm/autoconf.h.cygwin32 simgear/gdbm/autoconf.h
fi
])
echo ""
echo "Configure Summary"
@@ -259,3 +278,11 @@ if test "x$with_efence" != "x"; then
else
echo "Electric fence: no"
fi
if test "x$ac_cv_header_gdbm_h" != "xyes"; then
echo "Building gdbm"
fi
if test "x$ac_cv_header_zlib_h" != "xyes"; then
echo "Building zlib"
fi

View File

@@ -4,6 +4,12 @@ else
SERIAL_DIRS =
endif
if HAVE_GDBM
GDBM_DIRS =
else
GDBM_DIRS = gdbm
endif
if HAVE_ZLIB
ZLIB_DIRS =
else
@@ -20,6 +26,7 @@ include_HEADERS = compiler.h constants.h fg_traits.hxx fg_zlib.h version.h
SUBDIRS = \
bucket \
debug \
$(GDBM_DIRS) \
magvar \
math \
$(METAR_DIRS) \

View File

@@ -1,209 +0,0 @@
/* simgear/config.h. Generated automatically by configure. */
/* simgear/include/config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Define if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to eliminate all trace of debugging messages such as for a
release build */
/* #undef FG_NDEBUG */
/* Define to enable 3dfx/glide render in a window hack under unix.
This probably won't work under windows. */
/* #undef XMESA */
/* #undef FX */
/* Define if you don't have vprintf but do have _doprnt. */
/* #undef HAVE_DOPRNT */
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define if you have zlib installed system wide. */
/* #undef HAVE_ZLIB */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Define if compiling on a Winbloze (95, NT, etc.) platform */
/* #undef WIN32 */
/* Define if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
/* Define if you have the GetLocalTime function. */
/* #undef HAVE_GETLOCALTIME */
/* Define if you have the bcopy function. */
#define HAVE_BCOPY 1
/* Define if you have the ftime function. */
#define HAVE_FTIME 1
/* Define if you have the getitimer function. */
#define HAVE_GETITIMER 1
/* Define if you have the getrusage function. */
#define HAVE_GETRUSAGE 1
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the memcpy function. */
#define HAVE_MEMCPY 1
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
/* Define if you have the rand function. */
#define HAVE_RAND 1
/* Define if you have the random function. */
#define HAVE_RANDOM 1
/* Define if you have the rint function. */
#define HAVE_RINT 1
/* Define if you have the setitimer function. */
#define HAVE_SETITIMER 1
/* Define if you have the signal function. */
#define HAVE_SIGNAL 1
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the timegm function. */
#define HAVE_TIMEGM 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/timeb.h> header file. */
#define HAVE_SYS_TIMEB_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <values.h> header file. */
#define HAVE_VALUES_H 1
/* Define if you have the <winbase.h> header file. */
/* #undef HAVE_WINBASE_H */
/* Define if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define if you have the GL library (-lGL). */
#define HAVE_LIBGL 1
/* Define if you have the GLU library (-lGLU). */
/* #undef HAVE_LIBGLU */
/* Define if you have the GLcore library (-lGLcore). */
/* #undef HAVE_LIBGLCORE */
/* Define if you have the ICE library (-lICE). */
#define HAVE_LIBICE 1
/* Define if you have the MesaGL library (-lMesaGL). */
/* #undef HAVE_LIBMESAGL */
/* Define if you have the MesaGLU library (-lMesaGLU). */
#define HAVE_LIBMESAGLU 1
/* Define if you have the SM library (-lSM). */
#define HAVE_LIBSM 1
/* Define if you have the X11 library (-lX11). */
#define HAVE_LIBX11 1
/* Define if you have the Xext library (-lXext). */
#define HAVE_LIBXEXT 1
/* Define if you have the Xi library (-lXi). */
#define HAVE_LIBXI 1
/* Define if you have the Xmu library (-lXmu). */
#define HAVE_LIBXMU 1
/* Define if you have the Xt library (-lXt). */
#define HAVE_LIBXT 1
/* Define if you have the glut library (-lglut). */
#define HAVE_LIBGLUT 1
/* Define if you have the m library (-lm). */
#define HAVE_LIBM 1
/* Define if you have the socket library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Name of package */
#define PACKAGE "SimGear"
/* Version number of package */
#define VERSION "0.0.6"

View File

@@ -1,4 +1,4 @@
/* simgear/include/config.h.in. Generated automatically from configure.in by autoheader. */
/* simgear/config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
@@ -47,6 +47,9 @@
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* Define if you have gdbm installed system wide. */
#undef HAVE_GDBM
/* Define if you have zlib installed system wide. */
#undef HAVE_ZLIB

View File

@@ -26,6 +26,10 @@
#define _EPHEMERIS_HXX
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <plib/sg.h>
#include <Time/fg_time.hxx>

View File

@@ -57,77 +57,6 @@ Moon::Moon(FGTime *t) :
0.054900, 0.000000,
115.3654, 13.0649929509, t)
{
#if 0
int width, height;
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &moon_texid);
xglBindTexture(GL_TEXTURE_2D, moon_texid);
#elif GL_EXT_texture_object
xglGenTexturesEXT(1, &moon_texid);
xglBindTextureEXT(GL_TEXTURE_2D, moon_texid);
#else
# error port me
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// load in the texture data
FGPath tpath( current_options.get_fg_root() );
tpath.append( "Textures" );
tpath.append( "moon.rgb" );
if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
== NULL )
{
// Try compressed
FGPath fg_tpath = tpath;
fg_tpath.append( ".gz" );
if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
== NULL )
{
FG_LOG( FG_GENERAL, FG_ALERT,
"Error in loading moon texture " << tpath.str() );
exit(-1);
}
}
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGB,
256, 256,
0,
GL_RGB, GL_UNSIGNED_BYTE,
moon_texbuf);
// setup the halo texture
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &moon_halotexid);
xglBindTexture(GL_TEXTURE_2D, moon_halotexid);
#elif GL_EXT_texture_object
xglGenTexturesEXT(1, &moon_halotexid);
xglBindTextureEXT(GL_TEXTURE_2D, moon_halotexid);
#else
# error port me
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
setHalo();
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGBA,
256, 256,
0,
GL_RGBA, GL_UNSIGNED_BYTE,
moon_halotexbuf);
moonObject = gluNewQuadric();
#endif
}
Moon::Moon() :
@@ -143,63 +72,9 @@ Moon::Moon() :
Moon::~Moon()
{
//delete moonObject;
// delete moon_texbuf;
// delete moon_halotexbuf;
}
#if 0
static int texWidth = 256; /* 64x64 is plenty */
void Moon::setHalo()
{
int texSize;
//void *textureBuf;
GLubyte *p;
int i,j;
double radius;
texSize = texWidth*texWidth;
moon_halotexbuf = new GLubyte[texSize*4];
if (!moon_halotexbuf)
return; // Ugly!
p = moon_halotexbuf;
radius = (double)(texWidth / 2);
for (i=0; i < texWidth; i++) {
for (j=0; j < texWidth; j++) {
double x, y, d;
*p = 0xff;
*(p+1) = 0xff;
*(p+2) = 0xff;
x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y));
if (d < radius) {
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice
*(p+3) = (int)((double) 0x20 * (t*t));
} else {
*(p+3) = 0x00;
}
p += 4;
}
}
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
// GL_LUMINANCE,
// GL_UNSIGNED_BYTE, textureBuf);
//free(textureBuf);
}
#endif
/*****************************************************************************
* void Moon::updatePosition(FGTime *t, Star *ourSun)
* this member function calculates the actual topocentric position (i.e.)
@@ -322,95 +197,3 @@ void Moon::updatePosition(FGTime *t, double lat, Star *ourSun)
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
}
#if 0
/************************************************************************
* void Moon::newImage()
*
* This function regenerates a new visual image of the moon, which is added to
* solarSystem display list.
*
* Arguments: Right Ascension and declination
*
* return value: none
**************************************************************************/
void Moon::newImage()
{
fgLIGHT *l = &cur_light_params;
float moon_angle = l->moon_angle;
/*double x_2, x_4, x_8, x_10;
GLfloat ambient;
GLfloat amb[4];*/
int moonSize = 550;
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
if( moon_angle*RAD_TO_DEG < 100 )
{
FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" );
xglPushMatrix();
{
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
FG_LOG( FG_GENERAL, FG_INFO,
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
xglTranslatef(0.0, 60000.0, 0.0);
glEnable(GL_BLEND); // BLEND ENABLED
// Draw the halo...
if (current_options.get_textures())
{
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
glEnd();
}
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
xglEnable( GL_LIGHT0 );
// set lighting parameters
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
// Enable( GL_CULL_FACE );
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
//glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_ONE, GL_ONE);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// Draw the moon-proper
if (current_options.get_textures())
{
glBindTexture(GL_TEXTURE_2D, moon_texid);
gluQuadricTexture(moonObject, GL_TRUE );
}
gluSphere(moonObject, moonSize, 12, 12 );
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
}
xglPopMatrix();
glDisable(GL_LIGHTING); // Lighting Disabled.
}
else
{
}
}
#endif

View File

@@ -1,7 +1,7 @@
// magvar.cxx -- compute local magnetic variation given position,
// altitude, and date
//
// This is an implimentation of the NIMA WMM 2000
// This is an implementation of the NIMA (formerly DMA) WMM2000
//
// http://www.nima.mil/GandG/ngdc-wmm2000.html
//
@@ -15,6 +15,37 @@
// WMM2000 IGR2000 added 2/00 EAW
// Released under GPL 3/26/00 EAW
// Adaptions and modifications for the SimGear project 3/27/2000 CLO
//
// Removed all pow() calls and made static roots[][] arrays to
// save many sqrt() calls on subsequent invocations
// left old code as SGMagVarOrig() for testing purposes
// 3/28/2000 Norman Vine -- nhv@yahoo.com
//
// Put in some bullet-proofing to handle magnetic and geographic poles.
// 3/28/2000 EAW
// The routine uses a spherical harmonic expansion of the magnetic
// potential up to twelfth order, together with its time variation, as
// described in Chapter 4 of "Geomagnetism, Vol 1, Ed. J.A.Jacobs,
// Academic Press (London 1987)". The program first converts geodetic
// coordinates (lat/long on elliptic earth and altitude) to spherical
// geocentric (spherical lat/long and radius) coordinates. Using this,
// the spherical (B_r, B_theta, B_phi) magnetic field components are
// computed from the model. These are finally referred to surface (X, Y,
// Z) coordinates.
//
// Fields are accurate to better than 200nT, variation and dip to
// better than 0.5 degrees, with the exception of the declination near
// the magnetic poles (where it is ill-defined) where the error may reach
// 4 degrees or more.
//
// Variation is undefined at both the geographic and
// magnetic poles, even though the field itself is well-behaved. To
// avoid the routine blowing up, latitude entries corresponding to
// the geographic poles are slightly offset. At the magnetic poles,
// the routine returns zero variation.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -126,6 +157,8 @@ static double hnm[13][13];
static double sm[13];
static double cm[13];
static double root[13];
static double roots[13][13][2];
/* Convert date to Julian day 1950-2049 */
unsigned long int yymmdd_to_julian_days( int yy, int mm, int dd )
@@ -156,9 +189,10 @@ double rad_to_deg( double rad )
}
/* return variation (in degrees) given geodetic latitude (radians), longitude
(radians) ,height (km) and (Julian) date
N and E lat and long are positive, S and W negative
/*
* return variation (in radians) given geodetic latitude (radians),
* longitude(radians), height (km) and (Julian) date
* N and E lat and long are positive, S and W negative
*/
double SGMagVar( double lat, double lon, double h, long dat, double* field )
@@ -168,6 +202,159 @@ double SGMagVar( double lat, double lon, double h, long dat, double* field )
/* reference dates */
long date0_wmm2000 = yymmdd_to_julian_days(0,1,1);
double yearfrac,sr,r,theta,c,s,psi,fn,fn_0,B_r,B_theta,B_phi,X,Y,Z;
double sinpsi, cospsi, inv_s;
static int been_here = 0;
double sinlat = sin(lat);
double coslat = cos(lat);
/* convert to geocentric coords: */
// sr = sqrt(pow(a*coslat,2.0)+pow(b*sinlat,2.0));
sr = sqrt(a*a*coslat*coslat + b*b*sinlat*sinlat);
/* sr is effective radius */
theta = atan2(coslat * (h*sr + a*a),
sinlat * (h*sr + b*b));
/* theta is geocentric co-latitude */
r = h*h + 2.0*h * sr +
(a*a*a*a - ( a*a*a*a - b*b*b*b ) * sinlat*sinlat ) /
(a*a - (a*a - b*b) * sinlat*sinlat );
r = sqrt(r);
/* r is geocentric radial distance */
c = cos(theta);
s = sin(theta);
/* protect against zero divide at geographic poles */
inv_s = 1.0 / (s + (s == 0.)*1.0e-8);
/* zero out arrays */
for ( n = 0; n <= nmax; n++ ) {
for ( m = 0; m <= n; m++ ) {
P[n][m] = 0;
DP[n][m] = 0;
}
}
/* diagonal elements */
P[0][0] = 1;
P[1][1] = s;
DP[0][0] = 0;
DP[1][1] = c;
P[1][0] = c ;
DP[1][0] = -s;
// these values will not change for subsequent function calls
if( !been_here ) {
for ( n = 2; n <= nmax; n++ ) {
root[n] = sqrt((2.0*n-1) / (2.0*n));
}
for ( m = 0; m <= nmax; m++ ) {
double mm = m*m;
for ( n = max(m + 1, 2); n <= nmax; n++ ) {
roots[m][n][0] = sqrt((n-1)*(n-1) - mm);
roots[m][n][1] = 1.0 / sqrt( n*n - mm);
}
}
been_here = 1;
}
for ( n=2; n <= nmax; n++ ) {
// double root = sqrt((2.0*n-1) / (2.0*n));
P[n][n] = P[n-1][n-1] * s * root[n];
DP[n][n] = (DP[n-1][n-1] * s + P[n-1][n-1] * c) *
root[n];
}
/* lower triangle */
for ( m = 0; m <= nmax; m++ ) {
// double mm = m*m;
for ( n = max(m + 1, 2); n <= nmax; n++ ) {
// double root1 = sqrt((n-1)*(n-1) - mm);
// double root2 = 1.0 / sqrt( n*n - mm);
P[n][m] = (P[n-1][m] * c * (2.0*n-1) -
P[n-2][m] * roots[m][n][0]) *
roots[m][n][1];
DP[n][m] = ((DP[n-1][m] * c - P[n-1][m] * s) *
(2.0*n-1) - DP[n-2][m] * roots[m][n][0]) *
roots[m][n][1];
}
}
/* compute gnm, hnm at dat */
/* WMM2000 */
yearfrac = (dat - date0_wmm2000) / 365.25;
for ( n = 1; n <= nmax; n++ ) {
for ( m = 0; m <= nmax; m++ ) {
gnm[n][m] = gnm_wmm2000[n][m] + yearfrac * gtnm_wmm2000[n][m];
hnm[n][m] = hnm_wmm2000[n][m] + yearfrac * htnm_wmm2000[n][m];
}
}
/* compute sm (sin(m lon) and cm (cos(m lon)) */
for ( m = 0; m <= nmax; m++ ) {
sm[m] = sin(m * lon);
cm[m] = cos(m * lon);
}
/* compute B fields */
B_r = 0.0;
B_theta = 0.0;
B_phi = 0.0;
fn_0 = r_0/r;
fn = fn_0 * fn_0;
for ( n = 1; n <= nmax; n++ ) {
double c1_n=0;
double c2_n=0;
double c3_n=0;
for ( m = 0; m <= n; m++ ) {
double tmp = (gnm[n][m] * cm[m] + hnm[n][m] * sm[m]);
c1_n=c1_n + tmp * P[n][m];
c2_n=c2_n + tmp * DP[n][m];
c3_n=c3_n + m * (gnm[n][m] * sm[m] - hnm[n][m] * cm[m]) * P[n][m];
}
// fn=pow(r_0/r,n+2.0);
fn *= fn_0;
B_r = B_r + (n + 1) * c1_n * fn;
B_theta = B_theta - c2_n * fn;
B_phi = B_phi + c3_n * fn * inv_s;
}
/* Find geodetic field components: */
psi = theta - ((pi / 2.0) - lat);
sinpsi = sin(psi);
cospsi = cos(psi);
X = -B_theta * cospsi - B_r * sinpsi;
Y = B_phi;
Z = B_theta * sinpsi - B_r * cospsi;
field[0]=B_r;
field[1]=B_theta;
field[2]=B_phi;
field[3]=X;
field[4]=Y;
field[5]=Z; /* output fields */
/* find variation in radians */
/* return zero variation at magnetic pole X=Y=0. */
/* E is positive */
return (X != 0. || Y != 0.) ? atan2(Y, X) : (double) 0.;
}
#ifdef TEST_NHV_HACKS
double SGMagVarOrig( double lat, double lon, double h, long dat, double* field )
{
/* output field B_r,B_th,B_phi,B_x,B_y,B_z */
int n,m;
/* reference dates */
long date0_wmm2000 = yymmdd_to_julian_days(0,1,1);
double yearfrac,sr,r,theta,c,s,psi,fn,B_r,B_theta,B_phi,X,Y,Z;
/* convert to geocentric coords: */
@@ -187,7 +374,7 @@ double SGMagVar( double lat, double lon, double h, long dat, double* field )
c = cos(theta);
s = sin(theta);
/*zero out arrays */
/* zero out arrays */
for ( n = 0; n <= nmax; n++ ) {
for ( m = 0; m <= n; m++ ) {
P[n][m] = 0;
@@ -274,4 +461,4 @@ double SGMagVar( double lat, double lon, double h, long dat, double* field )
/* find variation, leave in radians! */
return atan2(Y, X); /* E is positive */
}
#endif // TEST_NHV_HACKS

View File

@@ -24,6 +24,10 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <iostream>
@@ -42,9 +46,6 @@ static int sgMoonOrbPreDraw( ssgEntity *e ) {
glDisable( GL_DEPTH_TEST );
glDisable( GL_FOG );
glBlendFunc ( GL_SRC_ALPHA, GL_ONE ) ;
// sgVec4 color;
// sgSetVec4( color, 0.0, 0.0, 0.0, 1.0 );
// glMaterialfv ( GL_FRONT_AND_BACK, GL_AMBIENT, color ) ;
return true;
}

View File

@@ -24,6 +24,10 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <iostream>

View File

@@ -22,6 +22,10 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <plib/ssg.h> // plib include
#include "sky.hxx"

View File

@@ -22,6 +22,10 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <plib/ssg.h>

View File

@@ -24,6 +24,10 @@
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <iostream>