# Matlab Mobile orientation sensor - Direction of the z-axis and Pitch angle ambiguity

12 views (last 30 days)
Alessandro Mezza on 13 Apr 2017
I'm using the Matlab Android sensor support package to acquire data form the orientation sensor of a mobile device.
I need to compute the looking direction of the z-axis in the 3D space.
To do so, I'd just need the azimuth and the pitch; while the azimuth is alright, I've a problem with the pitch:
the pitch is defined within the range [-90° +90°] and this yields to an ambiguity in the pitch angles. Holding the phone vertically (with the top side towards the ceiling) it gives a pitch of -90° as expected, but when it tilts either clockwise or counterclockwise about the x-axis the pitch increases approaching 0° in both cases.
Given a certain azimuth, if the phone tilts clockwise about the x-axis, the screen will start facing the floor, giving a certain z-axis looking direction; if it rotates counterclockwise the screen will face the ceiling, giving another looking direction for the z-axis. However in both cases there will be a pitch in the range [-90° 0°] symmetrically with respect to the initial vertical position.
How can be the direction of the z-axis determined by means of azimuth and pitch if the pitch value appears to make no difference between the tilt direction with respect the vertical position (top side up)?
Shouldn't the pitch be defined in the range [-180° +180°]?
Thanks a lot!