I am trying to convert my current gps coordinates and the desired gps coordinates to a compass heading. I am trying to use the equations for the great circle. When I compile I am getting this error. error: invalid operands of types 'double' and 'double' to binary 'operator%' I'm pretty sure it does not like my modulo operator, but because atan2 returns a value between -180 and 180 I need to use it.
double lat_gps, lon_gps, lat, lon;
float desired_heading;
desired_heading =atan2(cos(lat_gps)*sin(lat)-sin(lat_gps)*cos(lat)*sin(lon-lon_gps),sin(lon-lon_gps)*cos(lat));
desired_heading = (desired_heading*(180.0/3.14)+360.0) % 360.0;
motor_control(desired_heading);