Pages: [1]   Go Down
Author Topic: GPS direction  (Read 1374 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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; }
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


It looks strange indeed. I think what is meant is
Code:
      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)
Logged

Rob Tillaart

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

Offline Offline
Full Member
***
Karma: 0
Posts: 196
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No sir i did not understand the code
 smiley-neutral
Logged

Pages: [1]   Go Up
Jump to: