Question

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.

Was it helpful?

Solution

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()

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top