# Changeset 8085:36a142494ced

Ignore:
Timestamp:
01/17/08 23:29:54 (5 years ago)
Branch:
default
Message:

trac #1828 -- 3d documentation into the reference manual

Location:
sage/plot
Files:
8 edited

Unmodified
Removed
• ## sage/plot/plot3d/bugs.txt

 r7969 We draw a spiral of spheres: sage: v = [(sin(i),cos(i),i) for i in [-4,-3.5,..4]] sage: S = sum(sphere(v[i], size=1/2, color=((i-4)/8, 1/2,(4-i)/8)) for i in range(len(v))) sage: S.show(aspect_ratio=[1,1,1]) NOTE: The sphere above have holes in them.  This is a \emph{bug} in jmol. * Only the last jmol 3d image is displayed, e..g., in one notebook cell sage: x, y = var('x,y')
• ## sage/plot/plot3d/examples.py

 r7969 """ EXAMPLES of 3d Plots: r""" Introduction. First we draw a spiral of spheres: sage: S = sum(sphere((sin(i),cos(i),i), size=0.5,color=((i-4)/8.0, 0.5,(4-i)/8.0)) for i in [-4,-3.5,..4]) sage: S.show(aspect_ratio=[1,1,1]) (not yet written) """
• ## sage/plot/plot3d/list_plot3d.py

 r7962 """ 3d list plots List Plots """
• ## sage/plot/plot3d/parametric_plot3d.py

 r8035 """ 3d Parametric Plots Parametric Plots """ from shapes2 import line3d from texture import Texture from sage.plot.misc import ensure_subs def parametric_plot3d(f, urange, vrange=None, plot_points="automatic", **kwds): """ r""" Return a parametric three-dimensional space curve or surface. INPUTS: There are four ways to call this function: * parametric_plot3d([f_x, f_y, f_z], (u_min, u_max)): f_x, f_y, f_z are three functions and u_min and u_max \begin{itemize} \item \code{parametric_plot3d([f_x, f_y, f_z], (u_min, u_max))}:\\ $f_x, f_y, f_z$ are three functions and $u_{\min}$ and $u_{\max}$ are real numbers * parametric_plot3d([f_x, f_y, f_z], (u, u_min, u_max)) f_x, f_y, f_z can be viewed as functions of u \item \code{parametric_plot3d([f_x, f_y, f_z], (u, u_min, u_max))}:\\ $f_x, f_y, f_z$ can be viewed as functions of $u$ * parametric_plot3d([f_x, f_y, f_z], (u_min, u_max), (v_min, v_max)) f_x, f_y, f_z are each functions of two variables * parametric_plot3d([f_x, f_y, f_z], (u, u_min, u_max), (v, v_min, v_max)) f_x, f_y, f_z can be viewed as functions of u and v The INPUTS are as follows: \item \code{parametric_plot3d([f_x, f_y, f_z], (u_min, u_max), (v_min, v_max))}:\\ $f_x, f_y, f_z$ are each functions of two variables \item \code{parametric_plot3d([f_x, f_y, f_z], (u, u_min, u_max), (v, v_min, v_max))}: \\ $f_x, f_y, f_z$ can be viewed as functions of $u$ and $v$ \end{itemize} INPUT: f -- a 3-tuple of functions or expressions urange -- a 2-tuple (u_min, u_max) or a 3-tuple (u, u_min, u_max) NOTES: * By default for a curve any points where f_x, f_y, or f_z do \begin{enumerate} \item By default for a curve any points where f_x, f_y, or f_z do not evaluate to a real number are skipped. * Currently for a surface f_x, f_y, and f_z have to be defined \item Currently for a surface f_x, f_y, and f_z have to be defined everywhere. This will change. \end{enumerate} EXAMPLES: We demonstrate each of the four ways to call this function. 1. A space curve defined by three functions of 1 variable: \begin{enumerate} \item A space curve defined by three functions of 1 variable: sage: parametric_plot3d( (sin, cos, lambda u: u/10), (0, 20)) that sends u to u/10. 2. Next we draw the same plot as above, but using symbolic functions: \item Next we draw the same plot as above, but using symbolic functions: sage: u = var('u') sage: parametric_plot3d( (sin(u), cos(u), u/10), (u, 0, 20)) 3. We draw a parametric surface using 3 Python functions (defined using \item We draw a parametric surface using 3 Python functions (defined using lambda): sage: f = (lambda u,v: cos(u), lambda u,v: sin(u)+cos(v), lambda u,v: sin(v)) sage: parametric_plot3d(f, (0, 2*pi), (-pi, pi)) 4. The same surface, but where the defining functions are symbolic: \item The same surface, but where the defining functions are symbolic: sage: u, v = var('u,v') sage: parametric_plot3d((cos(u), sin(u) + cos(v), sin(v)), (u, 0, 2*pi), (v, -pi, pi)) We increase the number of plot points, and make the surface green and transparent: sage: parametric_plot3d((cos(u), sin(u) + cos(v), sin(v)), (u, 0, 2*pi), (v, -pi, pi), color='green', opacity=0.1, plot_points=[30,30]) sage: parametric_plot3d((cos(u), sin(u) + cos(v), sin(v)), (u, 0, 2*pi), (v, -pi, pi), color='green', opacity=0.1, plot_points=[30,30]) \end{enumerate} We call the space curve function but with polynomials instead of def parametric_plot3d_curve(f, urange, plot_points, **kwds): r""" This function is used internally by the \code{parametric_plot3d} command. """ from sage.plot.plot import var_and_list_of_values plot_points = int(plot_points) def parametric_plot3d_surface(f, urange, vrange, plot_points, **kwds): r""" This function is used internally by the \code{parametric_plot3d} command. """ if not isinstance(plot_points, (list, tuple)) or len(plot_points) != 2: raise ValueError, "plot_points must be a tuple of length 2" return ParametricSurface(g, (u_vals, v_vals), **kwds) def ensure_subs(f): if not hasattr(f, 'subs'): from sage.calculus.all import SR return SR(f) return f

• ## sage/plot/tachyon.py

 r7541 r""" 3D Plotting Using Tachyon The Tachyon 3D Ray Tracer Given any 3D graphics object one can compute a raytraced representation by typing \code{show(viewer='tachyon')}.  For example, we draw two translucent spheres that contain a red tube, and render the result using Tachyon. sage: S = sphere(opacity=0.8, aspect_ratio=[1,1,1]) sage: L = line3d([(0,0,0),(2,0,0)], thickness=10, color='red') sage: M = S + S.translate((2,0,0)) + L sage: M.show(viewer='tachyon') One can also directly control Tachyon, which gives a huge amount of flexibility.  For example, here we directly use Tachyon to draw 3 spheres on the coordinate axes.  Notice that the result is gorgeous: sage: t = Tachyon(xres=500,yres=500, camera_center=(2,0,0)) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t2', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1,0,0)) sage: t.texture('t3', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(0,1,0)) sage: t.texture('t4', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(0,0,1)) sage: t.sphere((0,0.5,0), 0.2, 't2') sage: t.sphere((0.5,0,0), 0.2, 't3') sage: t.sphere((0,0,0.5), 0.2, 't4') sage: t.show() AUTHOR: EXAMPLES: Three spheres on the coordinate axes: sage: t = Tachyon(xres=500,yres=500, camera_center=(2,0,0)) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t2', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1,0,0)) sage: t.texture('t3', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(0,1,0)) sage: t.texture('t4', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(0,0,1)) sage: t.sphere((0,0.5,0), 0.2, 't2') sage: t.sphere((0.5,0,0), 0.2, 't3') sage: t.sphere((0,0,0.5), 0.2, 't4') sage: t.show() Sphere's along the twisted cubic. sage: t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0))
Note: See TracChangeset for help on using the changeset viewer.