Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing a city's coordinates from above

As a little project I've been thinking to create a little Google Earth-like animation. I want to play back a timeline while rotating the globe to center over various cities. At present I can use the default view settings to render a globe with the cities indicated by points.

enter image description here

When I try to orient the camera with a view vector looking down on a city (for example Denver), I end up with the following:

enter image description here

The ViewVector needs to be computed for some point out in space above the globe. However my trial and error has not arrived on any sort of coherent viewpoint with most looking like they're "inside" the globe.

What I need help with is a function which given the latitude and longitude of a city choses a ViewVector placing the city at the "center" of the camera view. The code which produced the "inside the globe" view follows:

SC[{lat_, lon_}] := {Cos[lon \[Degree]] Cos[lat \[Degree]], 
   Sin[lon  \[Degree]] Cos[lat  \[Degree]], Sin[lat \[Degree]]};

Graphics3D[{
  Opacity[0.75],
  Sphere[{0, 0, 0}, 0.99 ],
  Map[Line[
 Map[SC,
  CountryData[#, "SchematicCoordinates"], {-2}]] &,
   CountryData["Countries"]], {Yellow, PointSize[Medium],
   Point[SC[CityData["Denver", "Coordinates"]]]
   }
  },
 Boxed -> False,
 SphericalRegion -> True,
 ViewVector -> {{0, 0, 0}, SC[CityData["Denver", "Coordinates"]]}
 ]
like image 614
speciousfool Avatar asked Oct 04 '11 09:10

speciousfool


1 Answers

When using ViewVector in the form ViewVector->{v1, v2}, the camera is sitting in point v1 and is pointed in the direction of v2. So in your example, the camera would be sitting in the origin and is pointed in the direction of Denver, which produces the "inside globe" view. To have the camera looking down at Denver the camera should be sitting in a point directly above the city, e.g. in 2 SC[CityData["Denver", "Coordinates"] and be pointed at the origin, so ViewVector would be something like

ViewVector -> {2 SC[CityData["Denver", "Coordinates"]], {0, 0, 0}}

With this setting for ViewVector the view becomes something like

enter image description here

like image 94
Heike Avatar answered Sep 23 '22 15:09

Heike