Ask Your Question
2

how to enhance this 3d implicit plot ?

asked 2017-02-12 21:32:22 +0200

FrédéricC gravatar image

updated 2017-02-12 21:49:56 +0200

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2017-02-13 03:12:05 +0200

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.

edit flag offensive delete link more

Comments

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

FrédéricC gravatar imageFrédéricC ( 2017-02-13 08:33:35 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-02-12 21:32:22 +0200

Seen: 404 times

Last updated: Feb 13 '17