I want to detect, if my smartphone user turn left or right or doing a turn around.
Here an example to explain "turn right":
The User faces a crossroad. Now I want to detect if my user takes the right path or the left path or goes straight on.
therefore i use this to get azimuth:
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
for (int i = 0; i < 3; i++) {
valuesAccelerometer[i] = event.values[i];
}
break;
case Sensor.TYPE_MAGNETIC_FIELD:
for (int i = 0; i < 3; i++) {
valuesMagneticField[i] = event.values[i];
}
break;
}
boolean success = SensorManager.getRotationMatrix(matrixR, matrixI,
valuesAccelerometer, valuesMagneticField);
if (success) {
SensorManager.getOrientation(matrixR, matrixValues);
Math.round(Math.toDegrees(Math.acos(matrixValues[0])));
azimuth = (float) Math.round(Math.toDegrees(matrixValues[0]));
if (azimuth < 0.0f) {
azimuth += 360.0f;
}
}
This works fine. But now i dont know how to set the start and the end point of my rotation...