r1933
dslinux_amadeus at dslinux.in-berlin.de
dslinux_amadeus at dslinux.in-berlin.de
Thu Sep 27 21:02:33 CEST 2007
Author: amadeus
Date: 2007-09-27 21:02:28 +0200 (Thu, 27 Sep 2007)
New Revision: 1933
Log:
Astro calculations need doubles.
Modified: trunk/user/pixil/apps/nanox/wclock/astro.c
===================================================================
--- trunk/user/pixil/apps/nanox/wclock/astro.c 2007-09-27 18:59:04 UTC (rev 1932)
+++ trunk/user/pixil/apps/nanox/wclock/astro.c 2007-09-27 19:02:28 UTC (rev 1933)
@@ -139,15 +139,15 @@
/* JTIME -- Convert internal GMT date and time to astronomical
Julian time (i.e. Julian date plus day fraction,
- expressed as a float). */
+ expressed as a double). */
-float
+double
jtime(t)
struct tm *t;
{
#ifdef NOTUSED
long val = t->tm_sec + (60L * (t->tm_min + 60L * t->tm_hour));
- float ret = (((float) (jdate(t) + val)) - 0.5) / 86400.0;
+ double ret = (((double) (jdate(t) + val)) - 0.5) / 86400.0;
return (ret);
#endif
@@ -158,11 +158,11 @@
/* KEPLER -- Solve the equation of Kepler. */
-float
+double
kepler(m, ecc)
- float m, ecc;
+ double m, ecc;
{
- float e, delta;
+ double e, delta;
#define EPSILON 1E-6
e = m = dtr(m);
@@ -186,11 +186,11 @@
void
sunpos(jd, apparent, ra, dec, rv, slong)
- float jd;
+ double jd;
int apparent;
- float *ra, *dec, *rv, *slong;
+ double *ra, *dec, *rv, *slong;
{
- float t, t2, t3, l, m, e, ea, v, theta, omega, eps;
+ double t, t2, t3, l, m, e, ea, v, theta, omega, eps;
/* Time, in Julian centuries of 36525 ephemeris days,
measured from the epoch 1900 January 0.5 ET. */
@@ -266,11 +266,11 @@
/* GMST -- Calculate Greenwich Mean Siderial Time for a given
instant expressed as a Julian date and fraction. */
-float
+double
gmst(jd)
- float jd;
+ double jd;
{
- float t, theta0;
+ double t, theta0;
/* Time, in Julian centuries of 36525 ephemeris days,
Modified: trunk/user/pixil/apps/nanox/wclock/main.c
===================================================================
--- trunk/user/pixil/apps/nanox/wclock/main.c 2007-09-27 18:59:04 UTC (rev 1932)
+++ trunk/user/pixil/apps/nanox/wclock/main.c 2007-09-27 19:02:28 UTC (rev 1933)
@@ -84,22 +84,22 @@
/* External functions - mainly to do math */
/* See astro.c for all the fun and games */
-extern void sunpos(float jd, int apparent, float *ra,
- float *dec, float *rv, float *slong);
+extern void sunpos(double jd, int apparent, double *ra,
+ double *dec, double *rv, double *slong);
-extern float jtime(struct tm *t);
-extern float gmst(float jd);
+extern double jtime(struct tm *t);
+extern double gmst(double jd);
void write_settings(void);
/* Translate latitude and longitude to X and Y positions */
static void
-translate(float lat, float lon, int *xpos, int *ypos)
+translate(double lat, double lon, int *xpos, int *ypos)
{
- *xpos = (int) ((180.0 + lon) * ((float) WIDTH / 360.0));
+ *xpos = (int) ((180.0 + lon) * ((double) WIDTH / 360.0));
*ypos =
- (int) ((float) HEIGHT - (lat + 90.0) * ((float) HEIGHT / 180.0));
+ (int) ((double) HEIGHT - (lat + 90.0) * ((double) HEIGHT / 180.0));
}
/* Copy the map to to the screen */
@@ -122,18 +122,18 @@
city_t *city = 0;
city_t *best_city = 0;
- float best_len = 999.0;
+ double best_len = 999.0;
for (city = city_head; city; city = city->next) {
int xpos, ypos;
- float dist;
+ double dist;
/* Translate the lat/lon */
translate(city->lat, city->lon, &xpos, &ypos);
/* Figure out the distance from the click */
- dist = hypot((float) abs(ex - xpos), (float) (ey - ypos));
+ dist = hypot((double) abs(ex - xpos), (double) (ey - ypos));
if (dist < best_len) {
best_city = city;
@@ -352,17 +352,17 @@
GR_REGION_ID region = GrNewRegion();
GR_GC_ID gc;
- float daywave[WIDTH];
+ double daywave[WIDTH];
/* Math variables */
- float sunra, sundec, sunrv, sunlon;
- float quot, cd, sd, shiftp;
- float f2, f3, spos, jgmt;
+ double sunra, sundec, sunrv, sunlon;
+ double quot, cd, sd, shiftp;
+ double f2, f3, spos, jgmt;
int hemi, i;
time_t now;
struct tm *gmt;
- float julian;
+ double julian;
/* Get the current UTC time */
@@ -375,7 +375,7 @@
/* Get the position of the sun */
sunpos(julian, 0, &sunra, &sundec, &sunrv, &sunlon);
- jgmt = (float) gmst(julian);
+ jgmt = (double) gmst(julian);
sunlon = fixangle(180.0 + (sunra - (jgmt * 15)));
/* Convert the sun x position on the map */
@@ -393,15 +393,15 @@
sd = sin(quot);
/* This is the radius of the sun */
- quot = (2.0 * M_PI) / (float) width;
+ quot = (2.0 * M_PI) / (double) width;
shiftp = 0.5 * (height + 1);
- f2 = ((float) height) / M_PI;
+ f2 = ((double) height) / M_PI;
f3 = 1E-8 * f2;
for (i = 0; i < width; i++) {
- float val = (float) i;
+ double val = (double) i;
daywave[i] = cos(quot * (val - spos));
}
More information about the dslinux-commit
mailing list