Viewing a city's coordinates from above

2019-05-02 10:18发布

问题:

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.

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:

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"]]}
 ]

回答1:

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