i am not getting the expected output with sensors in android
<p>I am new to android. I am developing an application that can measure height and width of any object using camera. For this application i am using the angle for calculating the distance.
But my problem is that i am not getting the angle in range of 0 to 180. Rather i am getting angle in just range of 0 to 90. After 90 degree it starts giving angle from 90 to 0.
so plz help me out. </p>

<pre><code>    mSM = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSM.getDefaultSensor(Sensor.TYPE_ORIENTATION);

    public void onSensorChanged(SensorEvent event) {
    //int sensor = event.type;
    float[] values = event.values;
    int i,flag = 0;
    StringBuffer str=new StringBuffer();
    // do something with the sensor data
    TextView text = (TextView) findViewById(R.id.my_text);
    float[] R = new float[9]; // rotation matrix
    float[] magnetic = new float[3];
    float[] orientation = new float[3];
    float[] I = new float[3];

    magnetic[0]=0;
    magnetic[1]=1;
    magnetic[2]=0;

    str.append("From Sensor :\n");
    for(i=0;i&lt;values.length; i++) {
        str.append(values[i]);
        str.append(", ");
    }

    SensorManager.getRotationMatrix(R, I, values, magnetic);
    SensorManager.getOrientation(R, orientation);


    str.append("\n\nGives :\n");
    if(orientation[1]==0.0)
        flag = 1;
    for(i=0;i&lt;orientation.length; i++) {
        str.append(Math.toDegrees(orientation[i]));
        str.append(", ");
    }
    str.append(" flag = "+flag);



    text.setText(str);
}
</code></pre>
