user6309391
user6309391

Reputation: 3

List of rotation matrix for object projection on screen in android

I have vector X and Y which I get from GPS latitude and longitude of my device position and the target object. Now to draw a marker on the target object on my screen I need to do some transformation to the vector. To transform I need to use rotation matrices. I have created a list of rotation matrices. But my point is not being drawn on the correct position. I think I m missing some rotation matrices. Below is the list

  1. Rotation for being landscape about X axis -90 degree
  2. Remap coordinate by after getting rotation by getrotation() method

My point is being shown to left of the main object. So its about Y axis I guess. My projection is correct as that's taken from opengl. So I think I am missing some rotation about Y axis. Please help.

Upvotes: 0

Views: 135

Answers (1)

Zahan Safallwa
Zahan Safallwa

Reputation: 3914

Yes you are missing a rotation about Y-axis. It is the error for the magnetic north not being same to true north. The magnetic north is moving to NW at a speed of 40km/year from true north. As a result you need to calculate the deflection of your magnetic sensor north at you position from true north.

Problem is this deflection is different at different position and different time. Android gives a method to calculate the deflection at any position given your latitude,longitude and current time. The method is getDeclination () and use it like below to get angle

 gmf = new GeomagneticField((float)Latitude,(float)Longitude,(float)Altitude, 
 System.currentTimeMillis());
 angleY = Math.toRadians(-gmf.getDeclination());

For reference take a look at GeomagneticField

Upvotes: 1

Related Questions