Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
554 views
in Technique[技术] by (71.8m points)

python - How to get axis ground in mayavi

As there are many questions (this, this and this) about axis grid in mayavi that how to get matplotlib type grid using mayavi and there is no satisfactory answer even from Mayavi updates.

So regarding above problem, there is an idea that we can add ground plane in Mayavi as object and then we can draw/show required objects on ground plane. Below is object that I draw as ground plane Ground plane Code for above draw ground is

x, y = np.mgrid[-10:10:200j, -10:10:200j]
z = np.sin(x * y) / (x * y)
mlab.figure(bgcolor=(1, 1, 1))
mlab.surf(z, colormap='cool')

mlab.show()

Let's say we have an object that we want to draw/show it on above ground plane. Below is object (as a example) object Code for above object is

mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
u, v = mgrid[- 0.035:pi:0.01, - 0.035:pi:0.01]

X = 2 / 3. * (cos(u) * cos(2 * v) + sqrt(2) * sin(u) * cos(v)) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
Y = 2 / 3. * (cos(u) * sin(2 * v) - sqrt(2) * sin(u) * sin(v)) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
Z = -sqrt(2) * cos(u) * cos(u) / (sqrt(2) - sin(2 * u) * sin(3 * v))
S = sin(u)

mlab.mesh(X, Y, Z, scalars=S, colormap='YlGnBu', )

mlab.view(.0, - 5.0, 4)
mlab.show()

This code is available here

So how we can draw given object on the given ground plane same like below image? I edit this image in photoshop for better view.

Object on ground

Looking for some kind suggestions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...