I know that accelerometer is for detecting rotation but is there any way to detect when phone is moving in the x and z axis instead of rotation. I have been doing research for days but nothing came up. Any idea or code snippet would be fine.
Just in case you are wondering what this is for, it is for mouse. Using a mobile device as a mouse. Thanks
I know this is a long time ago but I stumbled across this question so I thought I would answer anyway. Perhaps for someone else to use.
There’s no way to differentiate between a rotation and movement through space. The accelerometer is literally a measure of how much something is changing in speed. Since gravity is essentially a form of acceleration, you see the -9.8 applied constantly on the accelerometer.
But you could “fake it out” by moving your phone sideways at -9.8 m/s and down by 9.8m/s essentially cancelling out gravity on one axis and accelerating it along a different axis.
There’s no means of measuring absolutely position… (Well, there is the GPS/celphone tower orientation but the accuracy is really low for any valuable measure. It can be off by a meter or more).
This was a problem when working with the Wiimotes on the Wii.
Phones just don’t have the hardware in them yet.
Well from what i read, the samsung s8 onwards has support for translation capture for VR so… maybe that could work…