android - Orientation differences between Galaxy Tab and Transformer -
i developed augmented reality application using front-camera , min3d library. application works fine on samsung galaxy tab 10,1 (first generation), running android 4.0.4
but testing same application (landscape mode only) on asus transformer tf700t android 4.1.1 give wrong orientation , augmented world not match more camera view.
the following code used getting orientation vectors target_axis , up_axis needed min3d:
sensormanager.getrotationmatrix(mr, null, mlastaccelerometer, mlastmagnetometer); sensormanager.getorientation(mr, morientation); number3d target_axis = new number3d( -mr[2], -mr[5], -mr[8] ); number3d up_axis = new number3d( mr[1], mr[4], mr[7] ); the mlastaccelerometer , mlastmagnetometer received onsensorchanged(sensorevent event)
can tell me if above code still device dependent? expect using sensormanager's gerorientation call solution should work throughout different devices?
my guess related orientation of device, i.e. portrait, landscape, reverseportrait, reverselandscape etc. code posted naive, because doesn't take account of rotation of device relative default orientation. use following calculate azimuth adjustment
int rotation = activity.getwindowmanager().getdefaultdisplay().getrotation(); float screen_adjustment = 0; switch(rotation) { case surface.rotation_0: screen_adjustment = 0; break; case surface.rotation_90: screen_adjustment = (float)math.pi/2; break; case surface.rotation_180: screen_adjustment = (float)math.pi; break; case surface.rotation_270: screen_adjustment = 3*(float)math.pi/2; break; } which use in answer android compass can compensate tilt , pitch. other people suggest using sensormanager.remapcoordinatesystem(float[], int, int, float[]) depending on rotation number is.
Comments
Post a Comment