rephrase definition for android orientation angle "roll" - android

The definition of 'roll' in android is:
angle between a plane perpendicular to the device's screen and a plane perpendicular to the ground
See here.
Maybe I'm missing something, but there seem to be many planes perpendicular to the ground giving many different angles.
Could someone please rephrase this definition using e.g planes parallel to ground or screen, north direction, gravity direction?
NB! I am asking for a rephrasing using different words. I know the official definition as I have stated. Please don't repost the official definition.

From the mentioned docs:
Roll, angle of rotation about the y axis. This value represents the
angle between a plane perpendicular to the device's screen and a plane
perpendicular to the ground.
From another doc:
Roll (degrees of rotation about the y axis). This is the angle between
a plane perpendicular to the device's screen and a plane perpendicular
to the ground. If you hold the device parallel to the ground with the
bottom edge closest to you and tilt the left edge of the device toward
the ground, the roll angle becomes positive. Tilting in the opposite
direction—moving the right edge of the device toward the ground—
causes the roll angle to become negative. The range of values is -90
degrees to 90 degrees.
You may also have a look at that picture
The important point is about the y-axis. The y-axis is the one that goes positive from the bottom edge to the upper edge of the screen.
----EDIT----
A may be much more explicit picture here.

values[2]: Roll, angle of rotation about the y axis. This value represents the angle between a plane perpendicular to the device's screen and a plane perpendicular to the ground. Assuming that the bottom edge of the device faces the user and that the screen is face-up, tilting the left edge of the device toward the ground creates a positive roll angle. The range of values is -π/2 to π/2.
The plane "perpendicular to the ground" here is just a reference for how "tilted" (rolled) the device is. Imagine the device flat on a table next to a wall. If you lift the edge of the device so it is tilted to the side, the angle of roll is the angle between the plane of the device and the plane of the wall. This is because we have constrained the x axis (pitch) so that you are looking at roll. Now, if you lift the top of the device towards you, the roll stays the same while the pitch changes, because the device is still at the same angle towards the wall along it's y axis.

Related

Rotate 3d vector value into a single axis using a rotation quaternion

I want to rotate the whole value of a 3d vector into one axis using quaternion rotations.
The reason behind is that I want to align the X and Y Axis of my smartphone with the X and Y Axis of my vehicle in order to detect lateral and longitudinal acceleration separated on these two axis. Therefore I want to detect the first straight acceleration of the car and rotate the whole acceleration value into the heading axis (X-Axis) of the phone assuming a straight forward motion.
How do I achieve this?
I got it myself while this Link helped me a lot.
In the end I just needed to define the destination axis as a Vector V(Magnitude_Source, 0, 0), calculate the angle between V and the source vector and rotate the source vector.

How can I get horizontal rotation angle whatever device orientation?

I can get horizontal rotation angle by calculating the roll value (according to the definition of iOS Device Motion) when the device is portrait.
The x, y, z-axis of the mobile device:
But when the device is in landscape, y-axis is horizontal and x-axis is vertical. How can I get the angle? The pitch value is not correct. I have tried to exchange x and y in quaternion but not worked.
And more, how can I get the angle when the device is in the middle of portrait and landscape, for example, you tilt the device 30 degrees about z-axis?
Is there a unified quaternion or rotational matrix to calculate the angle whatever device orientation?
Probably you want to get angle of some device "direction". For example if you want to get angle of Z axis projected on ground, do it exactly.
Transform the Z(0,0,1) vector into current device rotation.
You have direction of "ZinWorld" vector in some world frame.
According to world frame orientation , project "ZinWorld" into ground plane. For example , if in default world frame Z is pointing to UP , then just take X Y components of "ZinWorld".
Take atan2(X, Y) to get proper angle.

What does x,y,z values obtained from accelerometer in Android indicate?

At first I thought:
x - tilting the phone from left - right and vice versa
y - upside down and vice versa
z - lifting the phone up and down
But it doesn't seem like that. Can anyone correct me if I am wrong.
I want to know these values in-order to know the angle of the phone. Is it possible to know it using these values?
Acceleration is a vector quantity, i.e. it has importance of its magnitude and also direction in which it is occurring.
Keeping this is mind and see image in link provided by Nicolai Ditlev Krogh Krüger, what we get is the right side of your phone is positive X direction, top side is positive Y direction and the screen side is positive Z direction.
Now Force=mass x acceleration
therefore acceleration = force/mass
Now force of gravity always acts on your device. To keep it from falling you have to apply equal force but in "OPPOSITE" direction.
Now when you put your phone on horizontal table, the table applies an upward force (from back of phone towards the screen), this is positive Z direction. So acceleration here is force/mass of your phone in positive Z direction. Since phone is not moving, means force by table equals gravity and there is no other force in any other directions as well. Force by gravity = mass x 9.8 (approx). Thus you see a value close to +10 for Z parameter of accelerometer and other two are near to zero.
Take one more example. This time hold your phone such that right side of phone is down and left side is up, and you hold your phone from near its ear piece and mic (opposite edges). In this scenario you are applying force against gravity upward, to keep your phone from falling, in negative X direction (remember that in phone positive X direction is pointing towards right side of phone). Thus you will see a value close to -10 for X parameter of accelerometer.
If user holds the phone at an angle (say a) from the horizontal plane (assume user tilt right side of phone down), then force of gravity becomes mass x 9.8 x Cos(a), where 'a' is in degree not radian, along the phone's X axis. Thus acceleration now becomes 9.8 x Cos(a). Since Max value of Cos(a)=1 (at a=0 degree), user will see a value less than 9.8 for X parameter of accelerometer for any other angle. If angle a= 60 degree (approx) then X parameter will show value close to 5, as Cos(60)= 0.5.
This is how the values change in the accelerometer output.
User can use the values of X, Y & Z to calculate actual angle of tilt of device from any plane (say horizontal plane).
Suppose X parameter is showing value 6. Then tilt is aCos(6/9.8) (that is Cos inverse and result will be in radians). To convert radians to degrees multiply by 180/pi. Thus final angle of tilt 'a' = aCos(6/9.8)*(180/pi) in degrees.
This how you come to know the tilt of your phone and use it to simulate force on digital objects on the screen. More tilt means more acceleration and hence more force.
After obtaining the values from accelerometer into mValuesAccel[3] and gravity values into mValuesMagnet[3],am executing the following methods.
enter code here
SensorManager.getRotationMatrix(mRotationMatrix, null, mValuesAccel,ValuesMagnet);
SensorManager.getOrientation(mRotationMatrix, mValuesOrientation);
After executing above methods, the values obtained in mValuesOrientation are:
mValuesOrientation[0]: i)if -ve X-axis faces west,then 0 degrees; ii)faces south, then -90 degrees;
iii)faces north, then -180 or 180degrees;
iv)faces east, then 90 degrees;
So, it lies between -180 degrees to 180 degrees
NOTE: 1)After converting the X value obtained into degrees, you will get the above values.
2)X-axis wil be from origin to right side,where your origin will be at bottom left of your phone.
mValuesOrientation[1]: if you lift your phone(which is lying on table) such that the top of phone faces sky, then you get -ve values, and +ve values in vice versa
mValuesOrientation[2]: if you move your phone(which is lying on table), like turning a paper in a book, to left side it gives -ve values and right side it gives +ve values.

Sensor value interpretation

I am currently trying to understand the sensor values I get from code similar to this.
The yaw/azimuth value seems to be okay. The problem is the pitch value, because I get -90° when the device is upright and tilting back and forward lead to the same values.
Lets say i tilt by 45° forward - the value is -45°, so its the same like tilting the device 45° backward.
Like this I cannot determine the device pitch in 360°.
Can somebody help me with that?
Taken from http://developer.android.com/reference/android/hardware/SensorListener.html:
All values are angles in degrees.
values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). 0 = North, 90 = East, 180 = South, 270 = West
values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive values when the z-axis moves toward the y-axis.
values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values when the z-axis moves toward the x-axis.
Note that this definition of yaw, pitch and roll is different from the traditional definition used in aviation where the X axis is along the long side of the plane (tail to nose).
So Pitch -180° - 180° instead of 0° - 360°. The difference is forward shows -45° and backward should show 45°, right?

Cube rotation issue in opengl android

I want to rotate the cube when the user is touching it. To rotate it,is quite simple but actual problem is if the user is tilting it then always it should stop in particuler face(cube has 6 faces and i mean that only one face should be visible at one time). Please give your suggetion if anyone worked on that.
In the case of a cube this is simple: Face normals are the cartesian axes. So one looks straigt on a face if you constrain the rotations around the cartesian axes (X, Y, Z) and the rotation angles are multiple of pi/2 = 90°.
So in your code when the user stops interacting, set the rotation angles to the next multiple of 90°
fmod(round(angle/90) * 90, 360); // degrees
fmod(round(angle/(pi/2)) * pi/2, 2*pi); // radians
Either do it hard, or animate it.
If your object is not a cube, but arbitrary, you need to find the additional rotation for the face to get perpendicular to the view axis. This angle is determined by acos( scalar_product(normalize(face_normal), normalize(view_axis)) ) the axis of rotation is given by cross_product(normalize(face_normal), normalize(view_axis))

Categories

Resources