Python3.0 Mayavi旋转立方体字形

问题描述 投票:0回答:1

使用mayavi points3d并使用立方体绘制图像。有没有办法在绘图期间将立方体旋转到某个方向?

mlab.figure(2)
mlab.points3d(GrainsFile[:,6],GrainsFile[:,7],GrainsFile[:,8],GrainsFile[:,11])

mayavi
1个回答
0
投票

我不得不搜索Mayavi代码。一旦我发现那些立方体是GlyphSource,我在其中一种方法中找到了一些转换操作:

import numpy
from mayavi import mlab

def test_points3d():
    t = numpy.linspace(0, 4 * numpy.pi, 20)

    x = numpy.sin(2 * t)
    y = numpy.cos(t)
    z = numpy.cos(2 * t)
    s = 2 + numpy.sin(t)

    points = mlab.points3d(x, y, z, s, colormap="viridis", scale_factor=.25,
    mode='cube')
    # rotate 45° on Z
    points.glyph.glyph_source._trfm.transform.rotate_z(45)
test_points3d()

points3d example rotated 45° on Z

© www.soinside.com 2019 - 2024. All rights reserved.