How can I covert Accelerometer data to degrees?
bladeolson
Member Posts: 295
I made an object that shows the degrees of the accelerometer. but the acceleromoter data is like 0.001 to 1.0 , is there a way to convert it to 0 to 360 derees? I tried to multiply by 100 and that got me half of it, but it does not work for the negative range of numbers.
I could use some help.
Thanks,
blade
I could use some help.
Thanks,
blade
Comments
0 * 360 = 0
0.5 * 360 = 180
1 * 360 = 360
Is that what you were looking for? I haven't messed with the accelerometers yet.
Does it go from 0 to 1, or does it actually go from -1 to 1?
Joe
So:
The accelerometer gives you a number in the range of [-1,1]
Multiply that by 180 to get a number in the range of [-180,180]
Add 180 to that to get a number in the range of [0,360]
Thus:
self.myAngle = ([AccelerometerValue] * 180) + 180
There are other ways to do this I'm sure, but that should get you what you need.
then it flips from 90+ again to go from .90 back to 0 again at 180 from the orginal position. So somehow I guess I need to determine if I am past 90 or 270 and adjust accordingly.
blade