I'm working on a project that measures wind direction and I'm stuck on this what appears to be a simple degree problem.
Example: Lets say I'm a compass (0' .. 360' ) now I'm pointing due north 0' , I want to take readings every minute and now I want to calculate the the minimal difference (relative to last reading) in degrees from the last reading..That is i want to calculate the shortest rotation in degrees that would get me to the current value
Assume we start at 0' Reading 1: 0' difference=0' Reading 2: 10' diff=10' (aka rotate right) Reading 3: 350 diff=20' (rotate left) reading 4: 180 diff=170' (rotate left)
My issue is that something like CurrentDeg- LastDeg =degChange doesn't work for boundary case for example
0 - 350 = -340 (It didnt roate 340 degreess but only 10', looking for minimal degree change - aka Relative offset)
Any help would be appreciated