First time here? Check out the FAQ!

Ask Your Question
2

how to enhance this 3d implicit plot ?

asked 8 years ago

FrédéricC gravatar image

updated 8 years ago

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...

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 7 years ago

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.

Preview: (hide)
link

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

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: 8 years ago

Seen: 516 times

Last updated: Feb 13 '17