#include "elastro.h" /* ///////////////////////////////////////////////////// ///// calculations used for guiding ///////////////// ///////////////////////////////////////////////////// // calculates sector of current position of arcsecons // 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 // az,alt, and altnorth must be given in arcseconds // altnorth must be the altitude position of the sky-northpole // normally this should be the latitude */ int gcalcSector( double az, double alt, double altnorth ) { int south; int upper; int sector; upper = 1; if( ( az >= ARC90 ) && ( az < ARC270 ) ){ south = 1; } else { south = 0; if( alt < altnorth ) { upper = 0; } } if( south ) { sector = 10; if( ( az >= ARC180 ) && ( az < ARC270 ) ){ sector = 12; } return( sector ); } sector = 0; if( ( az >= ARC270 ) && ( az <= ARC360 ) ){ sector = 2; } if( ! upper ){ sector++; } return( sector ); } /* // dependend of previous calculated sector // the direction of the az-motor will be calculated // returns 1 if az should be turn left, // otherwise 0 */ int gcalcAzDirLeft( int sector ) { switch( sector ) { case 0: return(1); case 2: return(1); default: break; } return(0); } /* // dependend of previous calculated sector // the direction of the alt-motor will be calculated // returns 1 if tubus should be turn down, // otherwise 0 */ int gcalcAltDirDown( int sector ) { switch( sector ) { case 2: return(1); case 3: return(1); case 12: return(1); default: break; } return(0); } /* // dependend of previous calculated sector // the direction of the fr-motor will be calculated // returns 1 if fr should be turn left, // otherwise 0 */ int gcalcFrDirLeft( int sector ) { switch( sector ) { case 0: return(1); case 1: return(1); case 2: return(1); case 3: return(1); default: break; } return(0); } /* // calculates radius of current koordinates ( to north, or southpole ) and // returnes it as number of arcseconds // az,alt,altnorth must be given as arcseconds // altnorth must be the altitude of current sky-northpole // ( must be latitude ) // if koordinates looks to south, the radius to the southpole will be returned. */ double gcalcR( double az, double alt,double altnorth, int sector ) { double x,y,altsouth; altsouth = altnorth + ARC180; x = 0; y = 0; switch( sector ) { case 0: x = az; y = alt - altnorth; break; case 1: x = az; y = altnorth - alt; break; case 2: x = ARC360 - az; y = alt - altnorth; break; case 3: x = ARC360 - az; y = altnorth - alt; break; case 10: x = ARC180 - az; y = altnorth + alt; break; case 12: x = ARC270 - az; y = altnorth + alt; break; default: return( -1 ); break; } return( sqrt( ( x * x ) + ( y * y ) ) ); } /* sector = gcalcSector( az, alt ); if( gcalcAzDirLeft( sector ) ) { //go left, otherwise right } if( gcalcAltDirDown( sector ) ) { //go down, otherwise up } if( gcalcFrDirLeft( sector ) ) { //rotate left, otherwise right } */