Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top