views:

778

answers:

3

I have a set of points starting from (0,0,0) charting a path taken by a vehicle in 3D with each point being the distance traveled in its respective dimension. I need to do 2 things

  1. Let (0,0,0) denote a latitude and longitude. How do I convert my set of points in 3D to it's equivalent in latitude and longitude?
  2. Plot it frame-by-frame (with a delay so it's usable for a video) on Google Maps/Earth/whatever

Any suggestions?

EDIT: Now the plotting is doable and the conversion isn't thanks to David

+1  A: 

It'd be easy to use JavaScript to animate points moving on a Google Map in your browser. I'm not sure what kind of video you are trying to get, though.

Google Maps even has an API method that will render a map with your path drawn over the map. You can see about this here at the bottom of the page.

David
Great link, I'm going to check it out now. What I'm trying to achieve is the "Timeline" effect on Google Earth .. but they only accept GPS data so either I convert my 3D coordinates to GPS or find an alternative. (Timeline: http://earth.google.com/intl/en/userguide/v5/ug_gps.html)
Jacob
Ok, so I've figured this out. I'm going to generate separate static maps for different portions of the path and use those images to create a video. Thanks!
Jacob
That's actually a great idea - you can generate the static maps at whatever interval / frame rate you need for the video.
Chris B
Exactly! Now, I have to figure out how to add distance (km) to a given longitude/latitude .. doesn't look so doable anymore!
Jacob
FYI... You are limited to generating 1,000 static Google Map images per day for your each key. This might effect how many frames you can create.
David
I need to make a 14000 frame video .. thanks for the heads up!
Jacob
+1  A: 

For Google Earth, there's a great example here: scroll down to "Example: Showing Movement of a Point Along a Path"

For the Google Maps API, This example was in the Google Maps Demo Gallery. It's kind of rough, but you get the idea of what you could do.

Chris B
+1  A: 

So you have a starting point (0,0) in one (arbitrary) coordinate system, and a corresponding (latitude, longitude) point in another (geocentric) coordinate system. Your problem is, given a set of known (x, y) offsets from your origin, how do you find the corresponding (latitude, longitude) points? (Am I understanding your question so far?)

The simple answer is just to use the formula:

lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ))
lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2))
d/R is the angular distance (in radians), where d is the distance travelled and R is the earth’s radius

Taken from this link: http://www.movable-type.co.uk/scripts/latlong.html

Edit 2: (Oh, I forgot to mention: this formula assumes you have polar coordinates (R, θ) instead of Cartesian coordinates (x, y). But converting between those is not too hard.)

The slightly longer answer is that if you are doing this over a large enough space, the math gets very complicated, because of how height is measured and how the surface of the earth is shaped. You probably want to read up on geographic coordinate systems; this Wikipedia article is a good starting point. You may also find the PROJ.4 library useful.

Edit:

If you need to take height (z) measurements into account, the math gets even more complex. The easy(ier) solution is to do 2.5-dimension math -- that is, calculate the (x, y) coordinate with one set of formulas, and then do the (z) coordinate separately. This only works over a small enough area, since you're essentially assuming that the surface of the earth is flat for the space you're working in. However, that may be good enough for your application.

Daniel Pryden