Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implicit equation and Mayavi

Tags:

python

mayavi

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.

like image 855
Johnny Avatar asked Jul 16 '26 03:07

Johnny


1 Answers

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

like image 81
unutbu Avatar answered Jul 18 '26 15:07

unutbu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!