Sharedsupport / 2017-03-17-104637-tachyon.sagewsOpen in CoCalc
Author: William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
t = Tachyon(xres=1000, yres=800, camera_center=(2,7,4), look_at=(2,0,0), raydepth=4) t.light((10,3,2), 1, (1,1,1)) t.light((10,-3,2), 1, (1,1,1)) t.texture('black', color=(0,0,0)) t.texture('red', color=(1,0,0)) t.texture('grey', color=(.9,.9,.9)) t.plane((0,0,0),(0,0,1),'grey') t.cylinder((0,0,0),(1,0,0),.01,'black') t.cylinder((0,0,0),(0,1,0),.01,'black') E = EllipticCurve('37a') P = E([0,0]) Q = P n = 100 for i in range(n): Q = Q + P c = i/n + .1 t.texture('r%s'%i,color=(float(i/n),0,0)) t.sphere((Q[0], -Q[1], .01), .04, 'r%s'%i) show(t)
Tachyon?
File: /projects/sage/sage-7.5/local/lib/python2.7/site-packages/sage/plot/plot3d/tachyon.py Docstring : Create a scene the can be rendered using the Tachyon ray tracer. INPUT: * "xres" - (default 350) * "yres" - (default 350) * "zoom" - (default 1.0) * "antialiasing" - (default "False") * "aspectratio" - (default 1.0) * "raydepth" - (default 5) * "camera_center" - (default (-3, 0, 0)) * "updir" - (default (0, 0, 1)) * "look_at" - (default (0,0,0)) * "viewdir" - (default "None"), otherwise list of three numbers * "projection" - "'PERSPECTIVE'" (default), "'perspective_dof'" or "'fisheye'". * "frustum" - (default ''), otherwise list of four numbers. Only used with projection='fisheye'. * "focallength" - (default ''), otherwise a number. Only used with projection='perspective_dof'. * "aperture" - (default ''), otherwise a number. Only used with projection='perspective_dof'. OUTPUT: A Tachyon 3d scene. Note that the coordinates are by default such that z is up, positive y is to the {left} and x is toward you. This is not oriented according to the right hand rule. EXAMPLES: Spheres along the twisted cubic. sage: t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0)) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0)) sage: t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0)) sage: k=0 sage: for i in srange(-1,1,0.05): ....: k += 1 ....: t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3)) sage: t.show() Another twisted cubic, but with a white background, got by putting infinite planes around the scene. sage: t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0), raydepth=8) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0)) sage: t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0)) sage: t.texture('white', color=(1,1,1)) sage: t.plane((0,0,-1), (0,0,1), 'white') sage: t.plane((0,-20,0), (0,1,0), 'white') sage: t.plane((-20,0,0), (1,0,0), 'white') sage: k=0 sage: for i in srange(-1,1,0.05): ....: k += 1 ....: t.sphere((i,i^2 - 0.5,i^3), 0.1, 't%s'%(k%3)) ....: t.cylinder((0,0,0), (0,0,1), 0.05,'t1') sage: t.show() Many random spheres: sage: t = Tachyon(xres=512,yres=512, camera_center=(2,0.5,0.5), look_at=(0.5,0.5,0.5), raydepth=4) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0)) sage: t.texture('t2', ambient=0.2, diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0)) sage: k=0 sage: for i in range(100): ....: k += 1 ....: t.sphere((random(),random(), random()), random()/10, 't%s'%(k%3)) sage: t.show() Points on an elliptic curve, their height indicated by their height above the axis: sage: t = Tachyon(camera_center=(5,2,2), look_at=(0,1,0)) sage: t.light((10,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(0,1,0)) sage: t.texture('t2', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(0,0,1)) sage: E = EllipticCurve('37a') sage: P = E([0,0]) sage: Q = P sage: n = 100 sage: for i in range(n): # increase 20 for a better plot ....: Q = Q + P ....: t.sphere((Q[1], Q[0], ZZ(i)/n), 0.1, 't%s'%(i%3)) sage: t.show() A beautiful picture of rational points on a rank 1 elliptic curve. sage: t = Tachyon(xres=1000, yres=800, camera_center=(2,7,4), look_at=(2,0,0), raydepth=4) sage: t.light((10,3,2), 1, (1,1,1)) sage: t.light((10,-3,2), 1, (1,1,1)) sage: t.texture('black', color=(0,0,0)) sage: t.texture('red', color=(1,0,0)) sage: t.texture('grey', color=(.9,.9,.9)) sage: t.plane((0,0,0),(0,0,1),'grey') sage: t.cylinder((0,0,0),(1,0,0),.01,'black') sage: t.cylinder((0,0,0),(0,1,0),.01,'black') sage: E = EllipticCurve('37a') sage: P = E([0,0]) sage: Q = P sage: n = 100 sage: for i in range(n): ....: Q = Q + P ....: c = i/n + .1 ....: t.texture('r%s'%i,color=(float(i/n),0,0)) ....: t.sphere((Q[0], -Q[1], .01), .04, 'r%s'%i) sage: t.show() # long time, e.g., 10-20 seconds A beautiful spiral. sage: t = Tachyon(xres=800,yres=800, camera_center=(2,5,2), look_at=(2.5,0,0)) sage: t.light((0,0,100), 1, (1,1,1)) sage: t.texture('r', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1,0,0)) sage: for i in srange(0,50,0.1): ....: t.sphere((i/10,sin(i),cos(i)), 0.05, 'r') sage: t.texture('white', color=(1,1,1), opacity=1, specular=1, diffuse=1) sage: t.plane((0,0,-100), (0,0,-100), 'white') sage: t.show() If the optional parameter "viewdir" is not set, the camera center should not coincide with the point which is looked at (see https://trac.sagemath.org/7232): sage: t = Tachyon(xres=80,yres=80, camera_center=(2,5,2), look_at=(2,5,2)) Traceback (most recent call last): ... ValueError: camera_center and look_at coincide Use of a fisheye lens perspective. sage: T = Tachyon(xres=800, yres=600, camera_center=(-1.5,-1.5,.3), projection='fisheye', frustum=(-1.0, 1.0, -1.0, 1.0)) sage: T.texture('t1', color=(0,0,1)) sage: cedges = [[[1, 1, 1], [-1, 1, 1]], [[1, 1, 1], [1, -1, 1]], ....: [[1, 1, 1], [1, 1, -1]], [[-1, 1, 1], [-1, -1, 1]], [[-1, 1, 1], ....: [-1, 1, -1]], [[1, -1, 1], [-1, -1, 1]], [[1, -1, 1], ....: [1, -1, -1]], ....: [[-1, -1, 1], [-1, -1, -1]], [[1, 1, -1], [-1, 1, -1]], ....: [[1, 1, -1], [1, -1, -1]], [[-1, 1, -1], [-1, -1, -1]], ....: [[1, -1, -1], [-1, -1, -1]]] sage: for ed in cedges: ....: T.fcylinder(ed[0], ed[1], .05, 't1') sage: T.light((-4,-4,4), .1, (1,1,1)) sage: T.show() Use of the "projection='perspective_dof'" option. This may not be implemented correctly. sage: T = Tachyon(xres=800,antialiasing=4, raydepth=10, projection='perspective_dof', focallength='1.0', aperture='.0025') sage: T.light((0,5,7), 1.0, (1,1,1)) sage: T.texture('t1', opacity=1, specular=.3) sage: T.texture('t2', opacity=1, specular=.3, color=(0,0,1)) sage: T.texture('t3', opacity=1, specular=1, color=(1,.8,1), diffuse=0.2) sage: T.plane((0,0,-1), (0,0,1), 't3') sage: ttlist = ['t1', 't2'] sage: tt = 't1' sage: T.cylinder((0,0,.1), (1,1/3,0), .05, 't3') sage: for q in srange(-3, 100, .15): ....: if tt == 't1': ....: tt = 't2' ....: else: ....: tt = 't1' ....: T.sphere((q, q/3+.3*sin(3*q), .1+.3*cos(3*q)), .1, tt) sage: T.show()
points = [(2,0,0), (0,2,0), (0,0,2), (-1,0,0), (0,-1,0), (0,0,-1)] show(LatticePolytope(points).plot3d(), viewer='tachyon')