Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed to calculate rotation-vector from Sensor.TYPE_ORIENTATION data
    primarykey
    data
    text
    <p>I need to calculate a rotation vector out of the data i get from Sensor.TYPE_ORIENTATION.</p> <p>The sensor data is defined like this:</p> <ul> <li>the values have to be recalculated to become a correct 3d position: values[0]: Azimuth, angle between the magnetic north direction and the Y axis, around the Z axis (0 to 359). 0=North, 90=East, 180=South, 270=West </li> <li>values<a href="https://github.com/bitstars/droidar" rel="nofollow noreferrer">1</a>: Pitch, rotation around X axis (-180 to 180), with positive values when the z-axis moves toward the y-axis. </li> <li>values[2]: Roll, rotation around Y axis (-90 to 90), with positive values when the x-axis moves away from the z-axis</li> </ul> <p>I need all three values like the Z axis value (from 0 to 360 degree). I tried a lot but cant figure out how to do this :/ </p> <p><strong>( edit: To see the idea behind in working code take a look at the class ActionWithSensorProcessing of the <a href="https://github.com/bitstars/droidar" rel="nofollow noreferrer">DroidAR framework</a> there you can see how the different event types can be processed.)</strong></p> <p>i also tried to use Sensor.TYPE_ACCELEROMETER and Sensor.TYPE_MAGNETIC_FIELD to calculate this 3d vector on my own. here is the code:</p> <pre><code>final float[] inR = new float[16]; // load inR matrix from current sensor data: SensorManager.getRotationMatrix(inR, null, gravityValues, geomagneticValues); float[] orientation = new float[3]; SensorManager.getOrientation(inR, orientation); mapMagAndAcclDataToVector(orientation); //here i do some *360 stuff orientetionChanged(orientation); //then the correct values are passed (in theorie) </code></pre> <p>But this didn't work and i think it is much to complicated. So i bet there is a simple solution how to recalc the values of ensor.TYPE_ORIENTATION to make them a 3d rotation vector, but i just dont know how to do it. If you know the answer please tell me.</p> <p>EDIT: i should add that i want to pass there values to OpenGL to align it to the axis like this:</p> <pre><code>gl.glRotatef(values[1], 1, 0, 0); gl.glRotatef(values[2], 0, 1, 0); gl.glRotatef(values[0], 0, 0, 1); </code></pre> <p>but because of the strange value ranges i obviously cant do this. the same problem with the values from SensorManager.getOrientation because they flip too when you pass the horizon line..</p> <p>another solution would be to calculate the angles using the inR matrix but i think there must be an easier solution (?)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload