#ifdef GVERSION1 typedef struct guidevalues { double nextazhs; double nextalths; double ra; double dec; double startLAST; double startTicks; } guidevalues; #endif #ifdef GVERSION2 typedef struct guidevalues { int startSector; double startTicks; double nextazhs; double nextalths; double arcperhsec; double hsecperarc; double arcper90; double radiusarc; double circumferencearc; } guidevalues; #endif static int gcalcSector( double azhs, double alths ); static void gcalcStart( double azhs, double alths, struct guidevalues *gv ); static void gcalcChangeSector( struct guidevalues * gv ); static int gcalcNext( struct guidevalues * gv ); static double TimGetHSecs( void ); // 1.0 / 360000.0 #define FHSEC 0.00000277777 #define STARDAYSECS 86164.0 #define STARDAYHSECS 8616400.0 #define STARDAYHSECS90 2154100.0 #define DAYSECS 86400.0 #define DAYHSECS 8640000.0 #define DAYHSECS90 2160000.0 ///////////////////////////////////////////////////// ///// calculations used for guiding ///////////////// ///////////////////////////////////////////////////// static double TimGetHSecs( void ) { return((double)TimGetTicks()); } // calculates sector of current position of halfsteps // returns: // north // 0 = az 0 - 90 alt >= pole // 1 = az 0 - 90 alt < pole // 2 = az 270 - 360 alt >= pole // 3 = az 270 - 360 alt < pole // south // 10 = az 90 - 180 // 12 = az 180 - 270 static int gcalcSector( double azhs, double alths ) { Boolean south; Boolean upper; int sector; upper = true; if( ( azhs >= scope.hs_az90 ) && ( azhs < scope.hs_az270 ) ){ south = true; } else { south = false; if( alths < scope.hs_northpole ) { upper = false; } } if( south ) { sector = 10; if( ( azhs >= scope.hs_az180 ) && ( azhs < scope.hs_az270 ) ){ sector = 12; } return( sector ); } sector = 0; if( ( azhs >= scope.hs_az270 ) && ( azhs <= scope.hs_az360 ) ){ sector = 2; } if( ! upper ){ sector++; } return( sector ); } #ifdef GVERSION1 //calculates all necessary values for guidingstart //azhs, and alths must be the current board-halfsteps. static void gcalcStart( double azhs, double alths, struct guidevalues * gv ) { gv->nextazhs = azhs; gv->nextalths = alths; cCurrentStarTime( scope.utcadjust, scope.longitude, 0 ); cRaDec( scope.latitude, ( azhs * scope.az_halfstepsize ) / 3600.0 , (alths * scope.alt_halfstepsize) / 3600.0 ); gv->ra = rectaszension; gv->dec = declination; gv->startLAST = LAST; gv->startTicks = TimGetHSecs(); } //calculates next koordinates ( gv->nextazhs, gv->nextalths ); static int gcalcNext( struct guidevalues * gv ) { double diff; diff = ( TimGetHSecs() - gv->startTicks ) / 360000.0; LAST = gv->startLAST + diff; cAzAlt( scope.latitude, gv->ra, gv->dec ); gv->nextazhs = ( azimuth * 3600.0 ) / scope.az_halfstepsize; gv->nextalths = ( altitude * 3600.0 ) / scope.alt_halfstepsize; return(1); } #endif #ifdef GVERSION2 //calculates all necessary values for guidingstart //azhs, and alths must be the current board-halfsteps. static void gcalcStart( double azhs, double alths, struct guidevalues * gv ) { double azarc,altarc,az,alt; double ra,dec; double x,y; double a,b,r,u; double ticks; gv->nextazhs = azhs; gv->nextalths = alths; gv->startSector = gcalcSector(azhs,alths); azarc = azhs * scope.az_halfstepsize; altarc = alths * scope.alt_halfstepsize; az = azarc / 3600.0; alt = altarc / 3600.0; switch( gv->startSector ) { case 0: x = azarc; y = altarc - scope.northpole; break; case 1: y = azarc; x = scope.northpole - altarc; break; case 2: y = 1296000.0 - azarc; x = altarc - scope.northpole; break; case 3: x = 1296000.0 - azarc; y = scope.northpole - altarc; break; case 10: x = 648000.0 - azarc; y = altarc + scope.northpole; break; case 12: y = azarc - 648000.0; x = altarc + scope.northpole; break; default:break; } gv->radiusarc = sqrt( ( x * x ) + ( y * y ) ); gv->circumferencearc = gv->radiusarc * 2.0 * PI; //arcseconds per 1/100 second. gv->arcperhsec = gv->circumferencearc / STARDAYHSECS; gv->hsecperarc = STARDAYHSECS / gv->circumferencearc; ///////////////////////////////////////////////////// r = gv->radiusarc; u = gv->circumferencearc; a = deg(asin( y / gv->radiusarc )); b = ( a / 360.0 ) * gv->circumferencearc; ticks = b * gv->hsecperarc; gv->startTicks = TimGetHSecs() - ticks - 2.0; } static void gcalcChangeSector( struct guidevalues * gv ) { double azhs,alths; switch( gv->startSector ) { case 0: azhs = scope.hs_az360 - 1.0; alths = (gv->radiusarc + scope.northpole) / scope.alt_halfstepsize; break; case 1: azhs = gv->radiusarc / scope.az_halfstepsize; alths = scope.hs_northpole + 1.0; break; case 2: azhs = scope.hs_az360 - ( gv->radiusarc / scope.az_halfstepsize ); alths = scope.hs_northpole - 1.0; break; case 3: azhs = 1.0; alths = (scope.northpole - gv->radiusarc) / scope.alt_halfstepsize; break; case 10: azhs = scope.hs_az180 + 1; alths = ( gv->radiusarc - scope.northpole ) / scope.alt_halfstepsize; break; case 12: /* nor result, because under the horizon, we stop here*/ guiderunning = 0; return; default:break; } gcalcStart(azhs,alths,gv); } //calculates next koordinates ( gv->nextazhs, gv->nextalths ); static int gcalcNext( struct guidevalues * gv ) { double a,r,u,b,x,y; double ticks,diffticks; double azarc,altarc; ticks = TimGetHSecs(); diffticks = ticks - gv->startTicks; u = gv->circumferencearc; b = gv->arcperhsec * diffticks; a = ( b / u ) * 360.0; if(a >= 90.0){ gcalcChangeSector(gv); return(0); } r = gv->radiusarc; y = sin( rad( a) ) * r; x = sqrt( ( r * r ) - ( y * y ) ); switch( gv->startSector ) { case 0: azarc = x; altarc = y + scope.northpole; break; case 1: azarc = y; altarc = scope.northpole - x; break; case 2: azarc = 1296000.0 - y; altarc = x + scope.northpole; break; case 3: azarc = 1296000.0 - x; altarc = scope.northpole - y; break; case 10: azarc = 648000.0 - x; altarc = y - scope.northpole; break; case 12: azarc = 648000.0 + y; altarc = x - scope.northpole; break; default:break; } gv->nextazhs = azarc / scope.az_halfstepsize; gv->nextalths = altarc / scope.alt_halfstepsize; return(1); } #endif