Java tutorial
//package com.java2s; //License from project: Apache License import android.util.Log; public class Main { private static final String TAG = "VRUtil"; public static void getEulerAngles(float[] headView, float[] output) { float pitch = (float) Math.asin((double) headView[6]); float yaw; float roll; if (Math.abs(headView[6]) < 0.9999999999D) { yaw = (float) Math.atan2((double) (-headView[2]), (double) headView[10]); roll = (float) Math.atan2((double) (-headView[4]), (double) headView[5]); } else { yaw = 0.0F; roll = (float) Math.atan2((double) headView[1], (double) headView[0]); } output[0] = -pitch; output[1] = -yaw; output[2] = -roll; float pitchAngle = (float) Math.toDegrees(output[0]); float yawAngle = (float) Math.toDegrees(output[1]); float rollAngle = (float) Math.toDegrees(output[2]); Log.e(TAG, String.format("pitchAngle=%f, yawAngle=%f, rollAngle=%f", pitchAngle, yawAngle, rollAngle)); } }