Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

William Stein's answer was very helpful for me, but I also wanted to animate output of a plot3d based function (specifically I was trying to animate a surface of revolution, therefore I was using the revolution_plot3d function, but it's the same idea). Essentially, if you look at how the tachyon string is created, you can recreate the functionality quite simply. Here's a function that allows you to combine a plot3d output with a Tachyon object.

from sage.plot.plot3d.base import flatten_list
from sage.plot.plot3d.transform import Transformation

def combineTachyonPlot(T,P):
    P = P.transform(scale=[-1,1,1]) # Tachyon does not have a right-hand-rule coordinate system
    render_params = P.default_render_params()
    return r"""
                  '\n'.join([x.str() for x in T._objects]),
                  '\n'.join(sorted([t.tachyon_str() for t in P.texture_set()])),

# Example how to use this

T = Tachyon(xres=1024,yres=576, camera_center=(0,20,20), updir=(0,0,1) , viewdir=(0,-20,-20), antialiasing=True)
T.light((4,3,5), 0.2, (1,1,1))
T.texture('bg', ambient=1, diffuse=1, specular=1, opacity=1, color=(1,1,1))

u,v = var('u,v')
P = plot3d(u^2+v^2,(-2,2),(-2,2))


You can add things to the Tachyon object as you see fit, lights, backgrounds, spheres, etc. You can also add a 2-dimensional plot to the variable P and Tachyon will render it as well.