The main problem is when I use the values returned by the sensor manager "as is" i.e. not modifying them in any way, the points are no where near where they should be. For example, say the point I wish to project is due north of my current location and at the same elevation. I shouldn't need to tilt (pitch) the phone up or down and when I hold the phone in the direction of north it should appear somewhere near the center of the phone screen. However, this is not the case, in reality for the point to appear on the center of the screen I need to do something like tilt the phone at the ground and orient it in a easterly direction for example.
I have made a nasty fix which means I subtract 90 from the roll or add 45 degrees to the pitch etc. However while this now projects the point on the center of the screen it ruins the projections of any other points (as I have fundamentally altered the sensor values). In my current implementation a point north of me may work but any points to the south do not work. My problem is probably something to do with the coordinates of the phone differing from my projected coordinates, but making the two "work" together is causing me some serious headaches. I can send you my projection code if it helps, I have really exhausted all ideas to solve my issue! Thanks for the reply On Aug 20, 5:15 pm, Peli <[email protected]> wrote: > > however, I can never seem to get accurate screen coordinates > > of the points. > > Could you specify what exactly your problem is? > Does it not work *at all*, or does it work basically, but points are > off by a few degrees? Or does it only work in one orientation of the > device (like in landscape mode), and fails in other orientations? > > Peliwww.openintents.orghttp://code.google.com/p/openintents/wiki/SensorSimulator > > On Aug 20, 4:55 pm, mscwd01 <[email protected]> wrote: > > > Hi, > > > I want to find the screen coordinates (X,Y) where a point represented > > by a latitude/longitude value would appear on the screen if you > > pointed your phone at it (much in the same way as Wikitude does). > > > Here is my code from my onSensorChanged() method: > > > public void onSensorChanged(SensorEvent event) { > > Sensor sensor = event.sensor; > > int type = sensor.getType(); > > > switch (type) { > > case Sensor.TYPE_MAGNETIC_FIELD: > > mags = event.values.clone(); > > isReady = true; > > break; > > case Sensor.TYPE_ACCELEROMETER: > > accels = event.values.clone(); > > break; > > case Sensor.TYPE_ORIENTATION: > > orients = event.values.clone(); > > break; > > } > > > if (mags != null && accels != null && isReady) { > > isReady = false; > > > SensorManager.getRotationMatrix(R, I, accels, mags); > > SensorManager.remapCoordinateSystem(R, > > SensorManager.AXIS_X, SensorManager.AXIS_Z, outR); > > SensorManager.getOrientation(outR, values); > > > azimuth = convert.radToDeg(values[0]); > > pitch= convert.radToDeg(values[1]); > > roll = convert.radToDeg(values[2]); > > > } > > > } > > > I convert the points I wish to project from their lat/lon spherical > > coordinates to Cartesian coordinates and perform a perspective > > projection using the roll, pitch and azimuth values returned by the > > sensor, however, I can never seem to get accurate screen coordinates > > of the points. > > > The matrices for roll, pitch and azimuth I use are: > > > // pan > > double[][] azimuthMat = { > > {Math.cos(azimuthValue), -Math.sin(azimuthValue), 0}, > > {Math.sin(azimuthValue), Math.cos(azimuthValue), 0}, > > {0, 0, 1},}; > > > // tilt > > double[][] pitchMat = { > > {Math.cos(pitchValue), 0, Math.sin(pitchValue)}, > > {0, 1, 0}, > > {-Math.sin(pitchValue), 0, Math.cos(pitchValue)}, > > }; > > // roll > > double[][] rollMat = { > > {1, 0, 0}, > > {0, Math.cos(rollValue), -Math.sin(rollValue)}, > > {0, Math.sin(rollValue), Math.cos(rollValue)}, > > }; > > > I also perform the necessary translation of the projection cener and > > the point to project e.g: > > > // Translate the point > > subtract(pointToProject, projectionCenter); > > ... where 'pointToProject' and 'projectionCenter' are double arrays > > holding the Cartesian coordinates of each location (i.e. camera lat/ > > lon and the point to project lat/lon) > > > I realise this is quite a complicated question to ask and I haven't > > provided all my projection code etc, however if someone feels they can > > help me out and may know how to achieve what i'm after - i'll post the > > whole code. > > > Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

