Ask Your Question
1

Bound box for parametric 3D plots?

asked 2014-01-14 08:25:21 +0100

davidsevilla gravatar image

I am trying to plot a parametric surface but only in a certain box in 3D space. Namely, I would like to get JMol to plot this:

var('s t')
p = [s^2, s^2+t^2, s^2+s*t+s+t]; q = s^2+t^2+s-t+1
parametric_plot3d((p[0]/q,p[1]/q,p[2]/q),(s,-5,5),(t,-5,5), points=[100,100])

but restricted to [0,1]x[0,1]x[0,1] (for example). I see that implicit plots work exactly like that, but the singular part of this surface looks quite ugly: http://imgur.com/5IxilIz.

I would be fine with tachyon too, but I haven't been able to figure out how to rotate the camera (I basically want to cut out a chunk of that surface to see a section).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-01-14 16:08:06 +0100

niles gravatar image

updated 2014-01-14 16:09:17 +0100

I don't know how to do exactly what you're asking for, but I came up with some other ideas that might still work for you. Basically, I tried different ways of restricting or reparametrizing the domain so that you get the part of the surface you want. Since the polynomials are quadratic, you can work with them by hand, but you could have Sage do some symbolic solving or numerical root finding if that helps.

Here's a simpler example of what I mean which gives (I think) reasonable output. I convert to polar coordinates and plot concentric annuli in different colors with different opacities. Depending on your purpose, an animation might be good too!

sage: var('s t')
(s, t)
sage: p = [s^2, s^2+t^2, s^2+s*t+s+t]; q = s^2+t^2+s-t+1

sage: var('r,a')
(r, a)
sage: p_polar = [_.subs(dict(zip((s,t),(r*cos(a),r*sin(a))))) for _ in p]
sage: p_polar
[r^2*cos(a)^2,
 r^2*cos(a)^2 + r^2*sin(a)^2,
 r^2*cos(a)^2 + r^2*cos(a)*sin(a) + r*cos(a) + r*sin(a)]
sage: q_polar = q.subs(dict(zip((s,t),(r*cos(a),r*sin(a)))))
sage: q_polar
r^2*cos(a)^2 + r^2*sin(a)^2 + r*cos(a) - r*sin(a) + 1

sage: bands = [parametric_plot3d([_/q_polar for _ in p_polar],(r,i*.1,(i+1)*.1),(a,0,2*pi), points=[300,200 + i*40], opacity=1-i/15, color=hue(i/15)) for i in range(15)]
sage: sum(bands)

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2014-01-14 08:25:21 +0100

Seen: 2,588 times

Last updated: Jan 14 '14