My first topic. ![]()
I'm working on a project for locating geostationary satellites and have already ran into an issue that I have been working on for a while now. posting on the forum was a last resort but I'm not sure what to do. i'm not a math wiz or anything and I don't fully understand all of the inner workings of what I'm doing.
The gamma calculation doesn't match or even get close to what I've been doing in online calculators. I know the answer of the equation should be close to 38.4 degrees but I am getting 1.44. I will have the screenshots of the equation I'm trying to copy at the bottom. I also ran the same equation ran through an online calculator and it turned out fine (close at least but I rounded variables).
//include libraries
#include <math.h>
//define constants
#define re 6378 //radius of earth
#define rs 42164 //radius of sat orbit
//define variables
float myLat = 33.78;
float myLon = -84.40;
//define satellite target(s)
float satLat = 0.0; //will always equal 0 bc its a geosat
float satLon = -105.0;
void setup(){
Serial.begin(9600);
Serial.print("earth radius: ");
Serial.print(re);
Serial.println();
Serial.print("orbit radius: ");
Serial.print(rs);
Serial.println();
Serial.print("antenna location: ");
Serial.print(myLat);
Serial.print(", ");
Serial.print(myLon);
Serial.println();
Serial.print("target sat is ");
Serial.print(satLon);
Serial.println();
Serial.println();
}
void calculate(){
//calculate gamma
double gamma = acos(sin(satLat) * sin(myLat) + cos(satLat) * cos(myLat) * cos(satLon - myLon));
Serial.print("gamma: ");
Serial.print(gamma);
Serial.println();
//calculate el
//double elevation = acos(sin(gamma) / sqrt(1 + sq(re / rs) - 2 * (re / rs) * cos(gamma)));
//Serial.println(elevation);
//calculate az
//double azimuth = asin(sin(abs(myLon - satLon)) * cos(0 / sin(gamma)));
//Serial.println(azimuth);
}
void loop(){
calculate();
delay(10000);
}
Serial Monitor output:
earth radius: 6378
orbit radius: 42164
antenna location: 33.78, -84.40
target sat is -105.00
gamma: 1.44
Pics:
another sc of gamma formula (big L is latitude and little l is longitude):
calculation of gamma in an example:
gamma equation in a calculator:


