我正在尝试用绘图绘制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个数字是什么意思?他们是角吗?弧度?哪个角度?
答案 0 :(得分: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)