public void getEulerAngles(float[] eulerAngles, int offset) { if (offset + 3 > eulerAngles.Length) { throw new IllegalArgumentException("Not enough space to write the result"); } float yaw, roll, pitch = (float)Math.Asin(mHeadView[6]); if ((float)Math.Sqrt(1.0F - mHeadView[6] * mHeadView[6]) >= GIMBAL_LOCK_EPSILON) { yaw = (float)Math.Atan2(-mHeadView[2], mHeadView[10]); roll = (float)Math.Atan2(-mHeadView[4], mHeadView[5]); } else { yaw = 0.0F; roll = (float)Math.Atan2(mHeadView[1], mHeadView[0]); } eulerAngles[(offset + 0)] = (-pitch); eulerAngles[(offset + 1)] = (-yaw); eulerAngles[(offset + 2)] = (-roll); }