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:
I used rotationmatrix to rotate camera vector (VectorN)
My english is not good, please help me resolve this problem.
Thanks!
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:
public static Vector3D multiVectorMatrix(Vector3D vector, float[] matrix)
{
Vector3D rs = new Vector3D();
if(matrix.length == 9)
{
rs.setX(vector.getX() * matrix[0] + vector.getY() * matrix[3] + vector.getZ() * matrix[6]);
rs.setY(vector.getX() * matrix[1] + vector.getY() * matrix[4] + vector.getZ() * matrix[7]);
rs.setZ(vector.getX() * matrix[2] + vector.getY() * matrix[5] + vector.getZ() * matrix[8]);
}
else if(matrix.length == 16)
{
rs.setX(vector.getX() * matrix[0] + vector.getY() * matrix[4] + vector.getZ() * matrix[8] + matrix[12]);
rs.setY(vector.getX() * matrix[1] + vector.getY() * matrix[5] + vector.getZ() * matrix[9]+ matrix[13]);
rs.setZ(vector.getX() * matrix[2] + vector.getY() * matrix[6] + vector.getZ() * matrix[10]+ matrix[14]);
}
return rs;
}
I used rotationmatrix to rotate camera vector (VectorN)
Code:
--------------------
Vector3D vectorN = new Vector3D(0,0,-1);
vectorN = multiVectorMatrix(vectorN, rotationMatrix);
My english is not good, please help me resolve this problem.
Thanks!