title: Transform Latitude,Longitude-Position on screen in augmented reality app
body: <p>This is my first post on this forum and I'm very new in programming. I want to build an application where I can see exactly where some gps-values are on my phone. I know a lot of applications, like junaio, mixare and others, but they only show the direction to the objects and they are not very accurate (they don't have the goal to project it on the exact position on screen) - so I want to build it myself. I program in android, but I think it would be the same on iPhone.</p>
  
  <p>I followed the steps suggested from <a href="https://stackoverflow.com/questions/8895104/find-restaurents-and-tourist-places-by-augmented-reality/8898301#8898301">dabhaid</a> :</p>
  
  <blockquote>
    <p>There are three steps.</p>
    
    <p>1) Determine your position and orientation using sensors.</p>
    
    <p>2) Convert from GPS coordinate space to a planar coordinate space by determining the relative position and bearing of known GPS coordinates using e.g great circle distance and bearing. (your devices stays at the origin of the coordinate space with this scheme)</p>
    
    <p>3) Do a perspective projection <a href="http://en.wikipedia.org/wiki/3D_projection#Perspective_projection" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/3D_projection#Perspective_projection</a> to figure out where on the plane that is your display (ok, your camera sensor) the objects should appear, so you can augment them.</p>
  </blockquote>
  
  <p><strong>Step 1:</strong> easy, I have the gps-position and all orientations from my mobile device (x,y,z). For further refinements, I can use some algorithm to smooth this values (average, low filter, whatever).</p>
  
  <p><strong>Step 2:</strong> I don't know, what is exactly meant by planar coordinate space. I have some different approaches to convert my gps coordinate space. One of them is ECEF (earth centered), where 0,0,0 is the center of the earth. Somehow, this doesn't look good to me, because every little change of ONE axis, results in changes of the other two axis. So if I change the altitude, all of the 3 axis will change. I don't know if I can follow step 3 with this coordinate system.
  In step 2 is mentioned: <strong>using haversine</strong> - this would give me the distance to the point, but I don't get x,y,z from it. Do I have to calculate x,y by <strong>using trigometry</strong> (bearing (alpha) + distance (hypotenuse)) ?</p>
  
  <p><strong>Step 3:</strong> This method looks really cool! If I have my coordinate space from <strong>Step 2</strong>, I can calculate <strong>d_x,d_y,d_z</strong> by using the formula on wikipedia. But after this step, I'm not finished yet because i just have the coordinates and for projecting it on my screen, I only need two coordinates? The text from wikipedia is continued by calculating <strong>b_x,b_y</strong> They use <strong>e_x,e_y,e_z</strong> which is the viewer's position relative to the display surface -> How can I get these values from my mobile device? (android/ios). Another approach, which is suggested from wikipedia is: Calculating <strong>b_x,b_y by</strong> by using the formula mentioned on wikipedia. In this formula they use s_x,s_y, which is the screen size and <strong>r_x,r_y</strong> which is the recording surface size. Again, how can I get the recording surface from my mobile device?</p>
  
  <p>I can't find anything for it on the internet. It seems that nobody on android/ios has ever implemented a perspective projection before...</p>
  
  <p>Thank you very much for all of your answeres! Also, links to useful sites would help!</p>