1. Check out our app, Forums for Android! Download and leave feedback here!

How to get Orientation

Discussion in 'Application Development' started by tannauit, Jul 11, 2010.

  1. tannauit

    tannauit New Member
    Thread Starter
    5

    Jul 11, 2010
    1
    0
    5
    student
    VietName
    Hi all,

    I want to do something with augmented reality(AR) application. Now, I try to get camera orientation.

    I used SensorManager to get values:
    values[0]: azimuth, rotation around the Z axis.
    values[1]: pitch, rotation around the X axis.
    values[2]: roll, rotation around the Y axis.


    And I also get RotationMatrix, But I can't get camera orientation.

    Here my code:
    Code (Text):
    1.  
    2. public static Vector3D multiVectorMatrix(Vector3D vector, float[] matrix)
    3.     {
    4.         Vector3D rs = new Vector3D();
    5.         if(matrix.length == 9)
    6.         {
    7.             rs.setX(vector.getX() * matrix[0] + vector.getY() * matrix[3] + vector.getZ() * matrix[6]);
    8.             rs.setY(vector.getX() * matrix[1] + vector.getY() * matrix[4] + vector.getZ() * matrix[7]);
    9.             rs.setZ(vector.getX() * matrix[2] + vector.getY() * matrix[5] + vector.getZ() * matrix[8]);
    10.         }
    11.         else if(matrix.length == 16)
    12.         {
    13.             rs.setX(vector.getX() * matrix[0] + vector.getY() * matrix[4] + vector.getZ() * matrix[8] + matrix[12]);
    14.             rs.setY(vector.getX() * matrix[1] + vector.getY() * matrix[5] + vector.getZ() * matrix[9]+ matrix[13]);
    15.             rs.setZ(vector.getX() * matrix[2] + vector.getY() * matrix[6] + vector.getZ() * matrix[10]+ matrix[14]);    
    16.         }
    17.         return rs;
    18.     }
    19.  
    20.  
    21.  
    I used rotationmatrix to rotate camera vector (VectorN)
    Code (Text):
    1.  
    2.  
    3. --------------------
    4. Vector3D vectorN = new Vector3D(0,0,-1);
    5. vectorN = multiVectorMatrix(vectorN, rotationMatrix);
    6.        
    7.  
    My english is not good, please help me resolve this problem.

    Thanks!
     

    Advertisement

Share This Page

Loading...