Implicit equation and Mayavi

对着背影说爱祢 提交于 2020-01-13 16:31:40

问题


How to plot implicit equation F(x,y,z)=0 with Mayavi? I tried with

import scipy as np
x, y, z = np.mgrid[-3:3:100j, -3:3:100j, -3:3:100j]
F = x**2/3**2 + y**2/2**2 + z**2/4**2 - 1

from enthought.mayavi import mlab
mlab.contour3d(F)
mlab.show()

but I don't get a part of ellipsoid. If I use parametrization and mesh then it's ok, but don't know how to plot it implicitly.


回答1:


Use contours = [0] to get the surface F(x,y,z) = 0:

import numpy as np
from enthought.mayavi import mlab

x, y, z = np.ogrid[-3:3:100j, -3:3:100j, -3:3:100j]
F = x**2/3**2 + y**2/2**2 + z**2/4**2 - 1
mlab.contour3d(F, contours = [0])
mlab.show()



来源:https://stackoverflow.com/questions/13563782/implicit-equation-and-mayavi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!