{"id":173,"date":"2012-07-11T14:33:37","date_gmt":"2012-07-11T14:33:37","guid":{"rendered":"http:\/\/mitat.tuu.fi\/?p=173"},"modified":"2012-07-11T14:34:14","modified_gmt":"2012-07-11T14:34:14","slug":"heading-difference","status":"publish","type":"post","link":"http:\/\/mitat.tuu.fi\/?p=173","title":{"rendered":"Heading difference"},"content":{"rendered":"<p>A problem that pops up always. When needing to calculate heading difference between two compass courses?<\/p>\n<p><code><br \/>\nfloat calculateHeadError(float heading, float target)<br \/>\n{<br \/>\n    #define PI2 PI*2.0<br \/>\n    while (heading<0) heading += PI2;\n    while (target<0) target += PI2;\n\n    while (heading>PI2) heading -= PI2;<br \/>\n    while (target>PI2) target -= PI2;<\/p>\n<p>    float res = heading-target;<\/p>\n<p>    if ((heading<PI) &#038;&#038; (target>PI))<br \/>\n    {<br \/>\n        res =(heading+PI2)-target;<br \/>\n    }<\/p>\n<p>    if ((heading>PI) && (target<PI))\n    {\n        res= (heading)-(target+PI2);\n    }\n    return res;\n}\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A problem that pops up always. When needing to calculate heading difference between two compass courses? float calculateHeadError(float heading, float target) { #define PI2 PI*2.0 while (headingPI2) target -= PI2; float res = heading-target; if ((headingPI)) { res =(heading+PI2)-target; } if ((heading>PI) &#038;&#038; (target<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,11],"tags":[],"class_list":["post-173","post","type-post","status-publish","format-standard","hentry","category-code","category-measured","category-snippet"],"_links":{"self":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=173"}],"version-history":[{"count":2,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/173\/revisions"}],"predecessor-version":[{"id":175,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/173\/revisions\/175"}],"wp:attachment":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=173"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}