Back to main page
Back to draw contents
This section shows how to draw implicit functions and surfaces.
Two implicit functions in 2d.
draw2d(terminal = eps, /* Since Maxima 5.23, default dimensions have been changed for terminals eps and pdf */
grid = true,
line_type = solid,
key = "y^2=x^3-2*x+1",
implicit(y^2=x^3-2*x+1, x, -4,4, y, -4,4),
line_type = dots,
key = "x^3+y^3 = 3*x*y^2-x-1",
implicit(x^3+y^3 = 3*x*y^2-x-1, x, -4,4, y, -4,4),
title = "Two implicit functions" );
Gnuplot is not the best tool for 3d modelling tasks, but with some tricks we can get implicit surfaces. We'd like to see Gnuplot with better support for this kind of jobs. The method used by Maxima is the marching cubes triangularization algorithm.
/* Union of two 3d objects */
draw3d(color = blue,
implicit(min((x-1)^2+(y-1)^2+(z-1)^2, x^6+y^6+z^6)=1,
x,-1.1,2.1,y,-1.1,2.1,z,-1.5,2.1),
surface_hide = true)$
/* Intersection of the same objects */
draw3d(color = blue,
implicit(max((x-1)^2+(y-1)^2+(z-1)^2, x^6+y^6+z^6)=1,
x,-0.1,1.1,y,0,1.3,z,-0.1,1.1),
surface_hide = true)$
Icosahedral symmetry. %phi is the golden ratio.
draw3d(enhanced3d = true,
x_voxel = 15,
y_voxel = 15,
z_voxel = 15,
implicit(2=(cos(x+%phi*y)+cos(x-%phi*y)+cos(y+%phi*z)+cos(y-%phi*z)+cos(z-%phi*x)+cos(z+%phi*x)),
x,-4,4,y,-4,4,z,-4,4),
palette = gray,
surface_hide = true)$
Some more examples, suggested to me by Wolfgang Lindner. We see here how different look the same surfaces plotted by different draw graphics objects: implicit vs spherical and cylindrical; the resulting triangles are evident in the first case.
scn1: gr3d(
color = red,
implicit(x^2+y^2+z^2=1,x,-1.5,1.5,y,-1.5,1.5,z,-1.5,1.5),
color = green,
implicit(2*x^2+2*y^2=1,x,-1.5,1.5,y,-1.5,1.5,z,-1.5,1.5),
surface_hide = true)$
scn2: gr3d(
color = red,
spherical(1,a,0,2*%pi,z,0,%pi),
color = green,
cylindrical(1/sqrt(2),z,-1.5,1.5,az,0,2*%pi),
surface_hide = true)$
/* adding intersection curves */
scn3: gr3d(
color = red,
spherical(1,a,0,2*%pi,z,0,%pi),
color = green,
cylindrical(1/sqrt(2),z,-1.5,1.5,az,0,2*%pi),
color = blue,
line_width = 3,
parametric(cos(t)/sqrt(2),
sin(t)/sqrt(2),
sqrt(1-(cos(t)/sqrt(2))^2-(sin(t)/sqrt(2))^2),
t,0,2*%pi),
parametric(cos(t)/sqrt(2),
sin(t)/sqrt(2),
-sqrt(1-(cos(t)/sqrt(2))^2-(sin(t)/sqrt(2))^2),
t,0,2*%pi),
surface_hide = true)$
draw(
columns = 3,
terminal = png,
pic_width = 900, /* Since Maxima 5.23, pic_width and pic_height are deprecated. */
pic_height = 400, /* See option dimensions */
scn1,scn2,scn3);
Now the union and intersection of the sphere and the cylinder.
draw(
columns = 2,
terminal = eps, /* Since Maxima 5.23, default dimensions have been changed for terminals eps and pdf. See options dimensions */
/* union */
gr3d(enhanced3d = true,
implicit(min(x^2+y^2+z^2,2*x^2+2*y^2)=1,
x,-1.5,1.5,y,-1.5,1.5,z,-1.5,1.5),
surface_hide = true,
palette = gray),
/* intersection */
gr3d(enhanced3d = true,
implicit(max(x^2+y^2+z^2,2*x^2+2*y^2)=1,
x,-1.5,1.5,y,-1.5,1.5,z,-1.5,1.5),
surface_hide = true,
palette = gray) )$
Implicit and wired surface.
draw3d(
enhanced3d = true,
wired_surface=true,
implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5)=0.015,
x,-1,1,y,-1.2,2.3,z,-1,1)) $
Back to main page
Back to draw contents