【问题标题】:How cameraposition in plotly worksplotly 中的相机位置如何工作
【发布时间】:2016-05-30 11:38:17
【问题描述】:

我正在尝试使用 plotly 绘制 3D 图形,并且需要调整摄像头位置。我发现有两种方法可以做到这一点:使用Scene 对象的camera 属性,或者使用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个数字是什么意思?它们是角度吗?在弧度?哪个角度?

【问题讨论】:

    标签: python 3d plotly


    【解决方案1】:

    以下是 Plotly 用于 3d 绘图的相机控件的说明:

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

    为了完整起见,这里是一个简短的总结:

    可以使用camera 代替cameraposition,因为它似乎有更简单的解释。

    摄像头位置由三个向量确定:upcentereye

    向上向量决定页面的向上方向。默认为(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)
    

    【讨论】:

    • 哦,太好了!这不完全是我问题的答案,但无论如何它解决了我的问题:) 实际上,我在相机和相机位置之间有点困惑,并考虑询问关于 camera 的第二个问题(如何使用 camera 放大),这就是那个未提出的问题的答案。 :) 无论如何,谢谢。
    • 我建议对答案进行编辑,添加您链接的页面的摘要,因为在 SO 上不鼓励仅链接答案。
    • 谢谢!抱歉跑偏了。我也复制到这里:stackoverflow.com/questions/35478791/… 这将在明天添加到官方 Plotly Python 文档中。
    • cameraposition 属性已被弃用 [ref: github.com/plotly/plotly.js/blob/master/src/plots/gl3d/layout/… 请改用camera
    • 相机角度控制的官方文档现在在这里:plot.ly/python/3d-camera-controls
    猜你喜欢
    • 1970-01-01
    • 2020-12-26
    • 1970-01-01
    • 2020-09-24
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    • 1970-01-01
    相关资源
    最近更新 更多