从上方查看城市的坐标 [英] Viewing a city's coordinates from above

查看:18
本文介绍了从上方查看城市的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个小项目,我一直在考虑制作一个类似于 Google 地球的动画.我想播放时间轴,同时将地球旋转到各个城市的中心.目前我可以使用默认的视图设置来渲染一个由点表示的城市的地球.

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:

需要为地球上方空间中的某个点计算 ViewVector.然而,我的反复试验并没有得出任何一致的观点,大多数看起来像是在地球内部".

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.

我需要帮助的是一个函数,该函数根据城市的纬度和经度选择一个 ViewVector,将城市置于相机视图的中心".产生地球内部"视图的代码如下:

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

推荐答案

当以 ViewVector->{v1, v2} 形式使用 ViewVector 时,相机是位于 v1 点,指向 v2 的方向.因此,在您的示例中,相机将位于原点并指向丹佛的方向,从而产生地球内部"视图.要让相机俯视丹佛,相机应该位于城市正上方的一个点,例如在 2 SC[CityData["Denver", "Coordinates"] 并指向原点,所以 ViewVector 将类似于

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

使用 ViewVector 的这个设置,视图变得像

With this setting for ViewVector the view becomes something like

这篇关于从上方查看城市的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆