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 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to