I have this sensor fused data coming from a GYRO-ACC-MAG-hardware sensor.
It's data (YAW-PITCH-ROLL) goes from -180
to +180
or -90
to +90
Which algorithm helps me offset this to an arbitrary position and also have no sign change to minus?
What I mean is: -180
to +180
for instance leads to 0
to 359
. And I want 0
not where 0
of the sensor is but also offset to a certain position. In other words, picture a circle. Now put a zero at an arbitrary position on that circle. Now rotate that circle around it's center point. The zero rotates along, so it is now at a different position than it was before, right? That's the idea.
What I did:
YAW + 180
leads to 0 to 359
. Pitch + 90
leads to 0 to 179
. Roll + 180
leads to 0 to 359
.
If I understand you correctly, you want to make use of the modulo operator:
double YAW360 = (YAW+180)%360;
See http://msdn.microsoft.com/en-us/library/0w4e0fzs.aspx
The modulo operator makes a division and returns the division remainder:
17 / 5 = 3 rest 2
Therefore:
17 % 5 = 2