Go Down

Topic: GPS direction (Read 1 time) previous topic - next topic

cutebuddy6

Sir i am facing difficulty in understanding the following part of the code kindly guide me


dir = myGPS.gprmc_course_to(dest_latitude, dest_longitude) - myGPS.gprmc_course();
      if (dir < 0) { dir += 360; }
      if (dir > 180) { dir -= 360; }

robtillaart


It looks strange indeed. I think what is meant is
Code: [Select]

      if (dir < 0) { dir += 360; }
      if (dir > 360) { dir -= 360; } // 180 -> 360


This code maps the direction to a value between 0 and 360. It is meant to correct over- and underflow of the subtraction.

Clear ?

PS, if you post code please use the [ code] tags (by means of the button)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

cutebuddy6

No sir i did not understand the code
:|

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy