# how to enhance this 3d implicit plot ? I have tried to reproduce a simple object (namely the intersection of 3 cylinders), which is a useful example for 3D printing, as follows:

sage: x, y, z = var('x,y,z')
sage: cm = colormaps.Blues
sage: cf = (x + y + z + 8) / 16
sage: f = max_symbolic(x*x + y*y, x*x + z*z, y*y + z*z) - 1
sage: N = 60
sage: implicit_plot3d(f,(x,-1.1,1.1),(y,-1.1,1.1),(z,-1.1,1.1),color=(cf,cm),plot_points=N)


This works, and is not too bad, but there is a strange effect along the crests where the cylinders intersects. Probably due to our marching cube algorithm.

This may be hard, but does anybody have an idea how to do something better ?

REFERENCE: page 15 of http://www.math.harvard.edu/~knill/3d...

edit retag close merge delete

Sort by » oldest newest most voted

How about drawing the individual cylindrical sections with parametric_plot3d:

var('u v')

p  = parametric_plot3d( [cos(u),sin(u),abs(cos(u))*v], (u,-3*pi/4,-pi/4), (v,-1,1))
p += parametric_plot3d( [cos(u),sin(u),abs(sin(u))*v], (u,-pi/4,pi/4), (v,-1,1))
p += parametric_plot3d( [cos(u),sin(u),abs(cos(u))*v], (u,pi/4,3*pi/4), (v,-1,1))
p += parametric_plot3d( [cos(u),sin(u),abs(sin(u))*v], (u,3*pi/4,5*pi/4), (v,-1,1))

p += parametric_plot3d( [cos(u),abs(cos(u))*v,sin(u)], (u,-3*pi/4,-pi/4), (v,-1,1))
p += parametric_plot3d( [cos(u),abs(sin(u))*v,sin(u)], (u,-pi/4,pi/4), (v,-1,1))
p += parametric_plot3d( [cos(u),abs(cos(u))*v,sin(u)], (u,pi/4,3*pi/4), (v,-1,1))
p += parametric_plot3d( [cos(u),abs(sin(u))*v,sin(u)], (u,3*pi/4,5*pi/4), (v,-1,1))

p += parametric_plot3d( [abs(cos(u))*v,cos(u),sin(u)], (u,-3*pi/4,-pi/4), (v,-1,1))
p += parametric_plot3d( [abs(sin(u))*v,cos(u),sin(u)], (u,-pi/4,pi/4), (v,-1,1))
p += parametric_plot3d( [abs(cos(u))*v,cos(u),sin(u)], (u,pi/4,3*pi/4), (v,-1,1))
p += parametric_plot3d( [abs(sin(u))*v,cos(u),sin(u)], (u,3*pi/4,5*pi/4), (v,-1,1))

show(p)


Live example with nice clean edges.

more

Indeed much nicer. But then the STL output is not yet good enough to handle such a union of pieces..