kopia lustrzana https://gitlab.com/Zwarf/picplanner
Correcting error of julian day calculations, make functions more C like
rodzic
776a1dce65
commit
3774597356
|
@ -11,46 +11,48 @@ float calc_rad_deg (float rad) {
|
|||
|
||||
|
||||
/* Get current time and date and return as a pointer to an array */
|
||||
int *calc_time_utc ()
|
||||
void calc_time_utc (int *time_utc)
|
||||
{
|
||||
time_t t;
|
||||
struct tm *tmp;
|
||||
int *time_utc;
|
||||
|
||||
t = time(NULL);
|
||||
tmp = gmtime(&t);
|
||||
|
||||
g_print ("UTC: %02d:%02d:%02d - %d.%d.%d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tmp->tm_mday, tmp->tm_mon+1, tmp->tm_year+1900);
|
||||
|
||||
int time_utc_array[6] = {tmp->tm_year+1900, tmp->tm_mon+1, tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec};
|
||||
time_utc = time_utc_array;
|
||||
return time_utc;
|
||||
*(time_utc) = tmp->tm_year+1900;
|
||||
*(time_utc+1) = tmp->tm_mon+1;
|
||||
*(time_utc+2) = tmp->tm_mday;
|
||||
*(time_utc+3) = tmp->tm_hour;
|
||||
*(time_utc+4) = tmp->tm_min;
|
||||
*(time_utc+5) = tmp->tm_sec;
|
||||
}
|
||||
|
||||
|
||||
/* Calculate the Julian Day */
|
||||
double calc_jd (int *time_utc)
|
||||
void calc_jd (int *time_utc, double *time_jd)
|
||||
{
|
||||
int year = *time_utc;
|
||||
int month = *(time_utc+1);
|
||||
float day = *(time_utc+2);
|
||||
int hour = *(time_utc+3);
|
||||
int min = *(time_utc+4);
|
||||
int sec = *(time_utc+5);
|
||||
float year = *time_utc;
|
||||
float month = *(time_utc+1);
|
||||
double day = *(time_utc+2);
|
||||
float hour = *(time_utc+3);
|
||||
float min = *(time_utc+4);
|
||||
float sec = *(time_utc+5);
|
||||
|
||||
g_print ("Seconds: %f, Minute: %f, Hour: %f, Day: %f, Month: %f, Year: %f\n",sec,min,hour,day,month,year);
|
||||
/* calculate a float type day number which is direct proportional to the time went by */
|
||||
day += hour/24 + min/60 + sec/3600;
|
||||
day += (hour + (min + sec/60.)/60.)/24.;
|
||||
|
||||
g_print ("Day: %02f, Month: %02d, Year:%02d",day,month,year);
|
||||
|
||||
double jd;
|
||||
g_print ("Day: %f, Month: %f, Year:%f\n",day,month,year);
|
||||
|
||||
if (month<=2){
|
||||
year --;
|
||||
month += 12;
|
||||
}
|
||||
jd = (int)(365.25*(year+4716)) + (int)(30.6001*(month+1)) + day + 2 - (int)(year/100) + (int)(year/400) - 1524.5;
|
||||
g_print ("Julian Day: %f\n",jd);
|
||||
|
||||
*time_jd = (int)(365.25*(year+4716.)) + (int)(30.6001*(month+1.)) - (int)(year/100.) + (int)(year/400.) + day + 2. - 1524.5;
|
||||
g_print ("Julian Day: %f\n",*time_jd);
|
||||
|
||||
/*Explanation:
|
||||
* There are 5 main parts in this calculation.
|
||||
|
@ -83,7 +85,6 @@ double calc_jd (int *time_utc)
|
|||
*
|
||||
* --> combining all of this leads to the above formula.
|
||||
*/
|
||||
return jd;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ float calc_deg_rad (float deg);
|
|||
|
||||
float calc_rad_deg (float rad);
|
||||
|
||||
int *calc_time_utc ();
|
||||
void calc_time_utc (int *time_utc);
|
||||
|
||||
double calc_jd (int *time_utc);
|
||||
void calc_jd (int *time_utc, double *time_jd);
|
||||
|
||||
double calc_sidereal_time(float longitude, double time_jd);
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
float *hand_milky_way(float latitude, float longitude, int *time_utc){
|
||||
|
||||
double time_jd;
|
||||
float right_ascension = 266.5;
|
||||
float declination = -29.00;
|
||||
g_print("Handler Milky Way\n");
|
||||
g_print("Handler Milky Way, Year: %d\n", *time_utc);
|
||||
/* translate time to JD */
|
||||
|
||||
double time_jd = calc_jd(time_utc);
|
||||
calc_jd(time_utc, &time_jd);
|
||||
|
||||
/* calculate siderial time */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <calculations.h>
|
||||
|
||||
float *hand_milky_way(float latitude, float longitude, int *time);
|
||||
float *hand_milky_way(float latitude, float longitude, int *time_utc);
|
||||
|
|
|
@ -89,8 +89,9 @@ static int calculate (GtkWidget *widget, gpointer data)
|
|||
float longitude = atof(gtk_entry_get_text (east_entry));
|
||||
g_print("Calculation ongoing\n");
|
||||
|
||||
int *time_utc_now = calc_time_utc ();
|
||||
hand_milky_way (latitude, longitude, time_utc_now);
|
||||
int time_utc_now[6];
|
||||
calc_time_utc (&time_utc_now[0]);
|
||||
hand_milky_way (latitude, longitude, &time_utc_now[0]);
|
||||
return 1;
|
||||
}
|
||||
static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
|
|
Ładowanie…
Reference in New Issue