I ran into a problem with a rotation sensor, with a type TYPE_ROTATION_VECTOR. Reading from the sensor seems inaccurate, or is it something bothering, it's hard for me to say. This is the code I use to ensure the actual rotation of the device:
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
if (prevRotMatrix == null) {
prevRotMatrix = new float[16];
SensorManager.getRotationMatrixFromVector(prevRotMatrix, event.values);
} else {
float[] deltas = new float[3];
SensorManager.getRotationMatrixFromVector(rotMatrix, event.values);
SensorManager.getAngleChange(deltas, rotMatrix, prevRotMatrix);
rotXVal += (float) Math.toDegrees(deltas[1]);
rotYVal += (float) Math.toDegrees(deltas[2]);
rotZVal += (float) Math.toDegrees(deltas[0]);
client.rotX(rotXVal);
client.rotY(rotYVal);
client.rotZ(rotZVal);
System.arraycopy(rotMatrix, 0, prevRotMatrix, 0, rotMatrix.length);
}
}
}
rotXVal, rotYVal rotZVal .
, , , - . , . , , , " " , , .
, Android Lollipop (Samsung Galaxy S6). KitKat (Samsung Galaxy Note 4), .
RotationVectorDemo. Lollipop, KitKat.
, - , . , , ?