I am aware that similar questions have been asked, but I can't seem to find the solution. I've been using this code to return a function, but it doesn't seem to work:
#include <math.h>
// Computes the bearing in degrees from the point A(a1,a2) to
// the point B(b1,b2). Note that A and B are given in terms of
// screen coordinates
double bearing(double a1, double a2, double deg, double degy) {
a1 = 37.40733;
a2 = -121.84855;
static const double TWOPI = 6.2831853071795865;
static const double RAD2DEG = 57.2957795130823209;
// if (a1 = b1 and a2 = b2) throw an error
double theta = atan2(deg - a1, degy + a2);
if (theta < 0.0)
theta += TWOPI;
return RAD2DEG * theta;
Serial.print(bearing);
}
I keep receiving this error message:
Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"
C:\Users\family\Documents\Arduino\GPStester\GPStester.ino: In function 'double bearing(double, double, double, double)':
GPStester:90: error: call of overloaded 'print(double (&)(double, double, double, double))' is ambiguous
Serial.print(bearing);
note: no known conversion for argument 1 from 'double(double, double, double, double)' to 'long unsigned int'
exit status 1 call of overloaded 'print(double (&)(double, double, double, double))' is ambiguous ambiguous
Serial.print(bearing);
appears to be unreachable code. - Mikel FSerial.print
is along unsigned int
. You are passing a pointer to a function to it. - R Sahufloat
anddouble
are 4 bytes.double
isn't double precision. - gre_gor