2016-02-18 36 views
0

我試圖用陰謀繪製3D圖形並需要調整攝像機位置。我發現有兩種方法可以做到這一點:或者用camera屬性的Scene對象,或者用cameraposition屬性。我對兩者都有問題,但是這個問題與cameraposition有關:我無法弄清楚它是什麼意思。如何在攝像機拍攝中工作

docs說:

|  cameraposition [required=False] (value=camera position list or 1d numpy 
|  array): 
|   Sets the camera position with respect to the scene. The first entry 
|   (a list or 1d numpy array of length 4) sets the angular position of 
|   the camera. The second entry (a list or 1d numpy array of length 3) 
|   sets the (x,y,z) translation of the camera. The third entry (a 
|   scalar) sets zoom of the camera. 
| 
|   Examples: 
|    [[0.2, 0.5, 0.1, 0.2], [0.1, 0, -0.1], 3] 

什麼的4個數字相機的角位置是什麼意思?他們是角度嗎?以弧度?哪些角度?

回答

2

這裏的Plotly的相機控制的3D繪圖的解釋:

http://nbviewer.jupyter.org/github/etpinard/plotly-misc-nbs/blob/master/3d-camera-controls.ipynb

爲了完整起見,這裏是一個簡短的總結:

它可以使用camera,而不是cameraposition作爲它似乎有更簡單的解釋。

相機位置由三個矢量確定:up,center,eye

向上矢量確定頁面上的向上方向。默認值爲(x=0, y=0, z=1),即z軸指向上。

中心向量確定有關場景中心的翻譯。默認情況下,沒有翻譯:中心向量是(x=0, y=0, z=0)

眼矢量確定有關原點的相機視點。默認值是(x=1.25, y=1.25, z=1.25)

也可以通過減小眼球向量的範數來放大。

name = 'eye = (x:0.1, y:0.1, z:1)' 
camera = dict(
    up=dict(x=0, y=0, z=1), 
    center=dict(x=0, y=0, z=0), 
    eye=dict(x=0.1, y=0.1, z=1) 
) 
fig = make_fig(camera, name) 
py.iplot(fig, validate=False, filename=name) 
+0

哦,很好!這不完全是我的問題的答案,但它解決了我的問題無論如何:)其實,我有點困惑之間的相機和相機位置和思考問第二個問題關於「相機」(如何放大與「相機」 ),這就是那個沒有提出問題的答案。 :) 不管怎樣,謝謝。 –

+0

我建議對答案進行編輯,添加鏈接頁面的摘要,因爲SO上的鏈接專用答案是不鼓勵的。 –

+0

謝謝!遺憾的是,我也在這裏複製:http://stackoverflow.com/questions/35478791/grab-camera-position-from-plotly-3d-graph/35497559#35497559 明天這將被添加到官方的Plotly Python文檔中。 – user1561393

相關問題