I'm trying to implement a simple augmented reality tool for Android. All it needs to do is take as input my location and device orientation and the location of another device and present a camera view with an icon overlaid in the appropriate place in an appropriate size.
I'm stuck in two places: I wrote code to get updates for the current azimuth, pitch, and roll of the device. The code looks like this: private final SensorEventListener goodListener = new SensorEventListener() { private float[] magneticValues; private float[] accelerometerValues; public void onAccuracyChanged(Sensor sensor, int accuracy) { } public void onSensorChanged(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_MAGNETIC_FIELD: magneticValues = event.values.clone(); break; case Sensor.TYPE_ACCELEROMETER: accelerometerValues = event.values.clone(); break; } if (magneticValues != null && accelerometerValues != null) { float[] outR = new float[9]; float[] orientationValues = new float[3]; SensorManager.getRotationMatrix(outR, null, accelerometerValues, magneticValues); SensorManager.getOrientation(outR, orientationValues); double azimuth = Math.toDegrees(orientationValues[0]); double pitch = Math.toDegrees(orientationValues[1]); double roll = Math.toDegrees(orientationValues[2]); } } When I use logging to read these values, they seem relatively stable, but they do not seem to correspond to angles around any natural set of axes, and I can't figure out what the numbers represent. How should I interpret these numbers? The tutorial at http://www.devx.com/wireless/Article/42482/0/page/3 takes a much simpler approach, but I cannot get it to work. Once I have my device's azimuth, pitch, and roll, along with my latitude and longitude and that of the other device, how can I determine where to put the icon on the screen? This seems to be a complicated geometry problem where we must imagine the view field of the camera as an infinite cone, project it onto the surface of the earth, and see if the other location is inside the projected area, but this seems awfully complicated. Is there a better way that I'm overlooking? Thanks! - Jeff -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en