2011-10-04 83 views
5

作爲一個小項目,我一直在考慮創建一個類似Google Earth的動畫。我想回放一個時間線,同時將地球旋轉到各個城市的中心。目前,我可以使用默認視圖設置來渲染具有點所示城市的地球儀。從上面查看城市的座標

enter image description here

當我嘗試查看矢量看不起城市(例如丹佛)以定向相機,我結束了以下內容:

enter image description here

的ViewVector需求在全球範圍內的某些空間點上進行計算。然而,我的試驗和錯誤還沒有達到任何一種連貫的觀點,大多數人看起來像他們在全球「內部」。

我需要幫助的是一個函數,給定城市的緯度和經度,選擇一個ViewVector,將城市置於攝像機視圖的「中心」。該公司生產的「全球內部」視圖的代碼如下:

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

讓我想起了視頻的同事提出的:HTTP ://www.youtube.com/watch v = U形4y0e1Jdcs? –

回答

10

當使用形式ViewVector->{v1, v2}ViewVector,相機坐在點v1和指出在v2方向。因此,在您的示例中,相機將坐在原點並指向丹佛的方向,從而產生「內部球體」視圖。要讓相機俯視丹佛,相機應該坐在城市正上方的一個點上,例如,在2 SC[CityData["Denver", "Coordinates"]並在原點指出,這樣ViewVector會像

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

使用此設置爲ViewVector的觀點變得像

enter image description here