First I have two point. For example (120.231234,23.123142) (120.231222,23.123145) and I want calculate the angle between two points.
How do I rewrite from the program?
#include <NewSoftSerial.h> // Add to library folder
#include <TinyGPS.h> // Add to library folder
TinyGPS gps;
NewSoftSerial nss(6, 255); // Yellow wire to pin 6
void setup() {
Serial.begin(115200);
nss.begin(4800);
Serial.println("Reading GPS");
}
void loop() {
bool newdata = false;
unsigned long start = millis();
while (millis() - start < 5000) { // Update every 5 seconds
if (feedgps())
newdata = true;
}
if (newdata) {
gpsdump(gps);
}
}
// Get and process GPS data
void gpsdump(TinyGPS &gps) {
float flat, flon, x,y,lat2,long2;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
x=flat,y=flon;
Serial.print(x-5, 4); Serial.print(", ");
Serial.println(y-4, 4);
float course_to (float x, float y, float lat2, float long2);
lat2=20,long2=123;
{
float dlon = radians(long2-x);
x = radians(x);
lat2 = radians(lat2);
float a1 = sin(dlon) * cos(lat2);
float a2 = sin(x) * cos(lat2) * cos(dlon);
a2 = cos(x) * sin(lat2) - a2;
a2 = atan2(a1, a2);
if (a2 < 0.0)
{
a2 += TWO_PI;
}
}
// Feed data as it becomes available
bool feedgps(){
while (nss.available()) {
if (gps.encode(nss.read()))
return true;
}
return false;
}