views:

326

answers:

5

It's been a while since my math in university, and now I've come to need it like I never thought i would.

So, this is what I want to achieve: Having a set of 3D points (geographical points, latitude and longitude, altitude doesn't matter), I want to display them on a screen, considering the direction I want to take into account. This is going to be used along with a camera and a compass , so when I point the camera to the North, I want to display on my computer the points that the camera should "see". It's a kind of Augmented Reality.

Basically what (i think) i need is a way of transforming the 3D points viewed from above (like viewing the points on google maps) into a set of 3d Points viewed from a side.

A: 

Well, you'll want some 3D vector arithmetic to move your origin, and probably some quaternion-based rotation functions to rotate the vectors to match your direction. There are any number of good tutorials on using quaternions to rotate 3D vectors (since they're used a lot for rendering and such), and the 3D vector stuff is pretty simple if you can remember how vectors are represented.

Aesin
+2  A: 

The conversion of Latitude and longitude to 3-D cartesian (x,y,z) coordinates can be accomplished with the following (Java) code snippet. Hopefully it's easily converted to your language of choice. lat and lng are initially the latitude and longitude in degrees:

lat*=Math.PI/180.0;
lng*=Math.PI/180.0;
z=Math.sin(-lat);
x=Math.cos(lat)*Math.sin(-lng);
y=Math.cos(lat)*Math.cos(-lng);

The vector (x,y,z) will always lie on a sphere of radius 1 (i.e. the Earth's radius has been scaled to 1).

From there, a 3D perspective projection is required to convert the (x,y,z) into (X,Y) screen coordinates, given a camera position and angle. See, for example, http://en.wikipedia.org/wiki/3D_projection

Chris Johnson
A: 

well, just a pice ov advice, you can plot this points into a 3d space (you can do easily this using openGL). You have to transforrm the lat/long into another system for example polar or cartesian. So starting from lat/longyou put the origin of your space into the center of the heart, than you have to transform your data in cartesian coord:

z= R * sin(long) x= R * cos(long) * sin(lat) y= R * cos(long) * cos(lat) R is the radius of the world, you can put it at 1 if you need only to cath the direction between yoour point of view anthe points you need "to see"

than put the Virtual camera in a point of the space you've created, and link data from your real camera (simply a vector) to the data of the virtual one.

The next stemp to gain what you want to do is to try to plot timages for your camera overlapped with your "virtual space", definitevly you should have a real camera that is a control to move the virtual one in a virtual space.

Lopoc
+2  A: 

It really depends on the degree of precision you require. If you're working on a high-precision, close-in view of points anywhere on the globe you will need to take the ellipsoidal shape of the earth into account. This is usually done using an algorithm similar to the one descibed here, on page 38 under 'Conversion between Geographical and Cartesian Coordinates':

http://www.icsm.gov.au/gda/gdatm/gdav2.3.pdf

If you don't need high precision the techniques mentioned above work just fine.

lguy
+1  A: 

could anyone explain me exactly what these params mean ? I've tried and the results where very weird so i guess i am missunderstanding some of the params for the perspective projection

*  {a}_{x,y,z} - the point in 3D space that is to be projected.
* {c}_{x,y,z} - the location of the camera.
* {\theta}_{x,y,z} - The rotation of the camera. When {c}_{x,y,z}=<0,0,0>, and {\theta}_{x,y,z}=<0,0,0>, the 3D vector <1,2,0> is projected to the 2D vector <1,2>.

* {e}_{x,y,z} - the viewer's position relative to the display surface. [1]