CPP :
=======================================================
double calcAzimuth(double SatLon, double SiteLat, double SiteLon, int Height_over_ocean=0)
{
double f = 1.00 / 298.257, // Earth flattning factor
r_sat=42164.57, // Distance from earth centre to satellite
r_eq=6378.14, // Earth radius
sinRadSiteLat=SIN(Radians(SiteLat)),
cosRadSiteLat=COS(Radians(SiteLat)),
Rstation = r_eq / ( std::sqrt( 1 - f*(2-f)*sinRadSiteLat*sinRadSiteLat ) ),
Ra = (Rstation+Height_over_ocean)*cosRadSiteLat,
Rz = Rstation*(1-f)*(1-f)*sinRadSiteLat,
alfa_rx = r_sat*COS(Radians(SatLon-SiteLon)) - Ra,
alfa_ry = r_sat*SIN(Radians(SatLon-SiteLon)),
alfa_rz = -Rz,
alfa_r_north = -alfa_rx*sinRadSiteLat + alfa_rz*cosRadSiteLat,
Azimuth = 0.00;
if (alfa_r_north < 0)
Azimuth = 180+Deg(ATAN(alfa_ry/alfa_r_north));
else
Azimuth = Rev(360+Deg(ATAN(alfa_ry/alfa_r_north)));
return Azimuth;
}
................
int pos = sat.getOrbitalPosition();
int satDir = pos < 0 ? eDiSEqC::WEST : eDiSEqC::EAST;
double SatLon = abs(pos)/10.00,
SiteLat = lnb->getDiSEqC().gotoXXLatitude,
SiteLon = lnb->getDiSEqC().gotoXXLongitude;
if ( lnb->getDiSEqC().gotoXXLaDirection == eDiSEqC::SOUTH )
SiteLat = -SiteLat;
if ( lnb->getDiSEqC().gotoXXLoDirection == eDiSEqC::WEST )
SiteLon = 360 - SiteLon;
if (satDir == eDiSEqC::WEST )
SatLon = 360 - SatLon;
double azimuth=calcAzimuth(SatLon, SiteLat, SiteLon );
double elevation=calcElevation( SatLon, SiteLat, SiteLon );
double declination=calcDeclination( SiteLat, azimuth, elevation );
double satHourAngle=calcSatHourangle( azimuth, elevation, declination, SiteLat );
//
// xphile: USALS fix for southern hemisphere
//
if (SiteLat >= 0)
{
//
// Northern Hemisphere
//
int tmp=(int)round( fabs( 180 - satHourAngle ) * 10.0 );
RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
if (satHourAngle < 180) // the east
RotorCmd |= 0xE000;
else // west
RotorCmd |= 0xD000;
}
else
{
//
// Southern Hemisphere
//
if (satHourAngle < 180) // the east
{
int tmp=(int)round( fabs( satHourAngle ) * 10.0 );
RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
RotorCmd |= 0xD000;
}
else
{ // west
int tmp=(int)round( fabs( 360 - satHourAngle ) * 10.0 );
RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
RotorCmd |= 0xE000;
}
}
http://cvs.tuxbox.org/cgi-bin/viewc.../lib/dvb/frontend.cpp?hideattic=0&view=markup