Module: sage.plot.plot3d.shapes2
Lines, Frames, Spheres, Points, Dots, and Text
Module-level Functions
a, b) |
['x0', 'y0', 'z0'], ['x1', 'y1', 'z1']) |
lower_left, upper_right) |
Draw a frame in 3d.
lower_left, upper_right, label_lower_left, label_upper_right, [eps=1]) |
points, [thickness=1], [radius=None], [arrow_head=False]) |
Draw a 3d line joining a sequence of points.
One may specify either a thickness or radius. If a thickness is specified, this line will have a constant diameter regardless of scaling and zooming. If a radius is specified, it will behave as a series of cylinders.
Input:
A line in 3-space:
sage: line3d([(1,2,3), (1,0,-2), (3,1,4), (2,1,-2)])
The same line but red:
sage: line3d([(1,2,3), (1,0,-2), (3,1,4), (2,1,-2)], color='red')
A transparent thick green line and a little blue line:
sage: line3d([(0,0,0), (1,1,1), (1,0,2)], opacity=0.5, radius=0.1, \ color='green') + line3d([(0,1,0), (1,0,2)])
A Dodecahedral complex of 5 tetrahedrons (a more elaborate examples from Peter Jipsen):
sage: def tetra(col): ... return line3d([(0,0,1), (2*sqrt(2.)/3,0,-1./3), (-sqrt(2.)/3, sqrt(6.)/3,-1./3),\ ... (-sqrt(2.)/3,-sqrt(6.)/3,-1./3), (0,0,1), (-sqrt(2.)/3, sqrt(6.)/3,-1./3),\ ... (-sqrt(2.)/3,-sqrt(6.)/3,-1./3), (2*sqrt(2.)/3,0,-1./3)],\ ... color=col, thickness=10, aspect_ratio=[1,1,1]) ... sage: v = (sqrt(5.)/2-5/6, 5/6*sqrt(3.)-sqrt(15.)/2, sqrt(5.)/3) sage: t = acos(sqrt(5.)/3)/2 sage: t1 = tetra('blue').rotateZ(t) sage: t2 = tetra('red').rotateZ(t).rotate(v,2*pi/5) sage: t3 = tetra('green').rotateZ(t).rotate(v,4*pi/5) sage: t4 = tetra('yellow').rotateZ(t).rotate(v,6*pi/5) sage: t5 = tetra('orange').rotateZ(t).rotate(v,8*pi/5) sage: show(t1+t2+t3+t4+t5, frame=False)
v, [size=1]) |
Plot a point or list of points in 3d space.
Input:
sage: sum([point3d((i,i^2,i^3), size=5) for i in range(10)])
start, end, [ticks=4], [sub_ticks=4], [absolute=False], [snap=False]) |
lower_left, upper_right, [ticks=4], [sub_ticks=4]) |
[center=(0, 0, 0)], [size=1]) |
Return a plot of a sphere of radius size centered at
.
Input:
A simple sphere:
sage: sphere()
Two spheres touching:
sage: sphere(center=(-1,0,0)) + sphere(center=(1,0,0), aspect_ratio=[1,1,1])
Spheres of radii 1 and 2 one stuck into the other:
sage: sphere(color='orange') + sphere(color=(0,0,0.3), \ center=(0,0,-2),size=2,opacity=0.9)
We draw a transparent sphere on a saddle.
sage: u,v = var('u v') sage: saddle = plot3d(u^2 - v^2, (u,-2,2), (v,-2,2)) sage: sphere((0,0,1), color='red', opacity=0.5, aspect_ratio=[1,1,1]) + saddle
txt, ['x', 'y', 'z']) |
Display 3d text.
Input:
This function is called implicitly when you use the text command with a 3d position.
NOTE: There is no way to change the font size or opacity yet.
We write the word SAGE in red at position (1,2,3):
sage: text("SAGE", (1,2,3), color=(0.5,0,0))
We draw a multicolor spiral of numbers:
sage: sum([text('%.1f'%n, (cos(n),sin(n),n), color=(n/2,1-n/2,0)) \ for n in [0,0.2,..,8]])
size) |
Class: Line
This line has a fixed diameter unaffected by transformations and zooming.
It may be smoothed if corner_cutoff < 1
.
Input:
sage: from sage.plot.plot3d.shapes2 import Line sage: Line([(i*math.sin(i), i*math.cos(i), i/3) for i in range(30)], \ arrow_head=True)
Smooth angles less than 90 degrees:
sage: Line([(0,0,0),(1,0,0),(2,1,0),(0,1,0)], corner_cutoff=0)
self, points, [thickness=5], [corner_cutoff=0.5], [arrow_head=False]) |
Functions: bounding_box,
corners,
jmol_repr,
obj_repr,
tachyon_repr
self, [corner_cutoff=None], [max_len=None]) |
Figures out where the curve turns too sharply to pretend it's smooth.
Input: Maximum cosine of angle between adjacent line segments before adding a corner
Output: List of points at which to start a new line. This always includes the first point, and never the last.
Every point:
sage: from sage.plot.plot3d.shapes2 import Line sage: Line([(0,0,0),(1,0,0),(2,1,0),(0,1,0)], corner_cutoff=1).corners() [(0, 0, 0), (1, 0, 0), (2, 1, 0)]
Greater than 90 degrees:
sage: Line([(0,0,0),(1,0,0),(2,1,0),(0,1,0)], corner_cutoff=0).corners() [(0, 0, 0), (2, 1, 0)]
No corners:
sage: Line([(0,0,0),(1,0,0),(2,1,0),(0,1,0)], corner_cutoff=-1).corners() (0, 0, 0)
An intermediate value:
sage: Line([(0,0,0),(1,0,0),(2,1,0),(0,1,0)], corner_cutoff=.5).corners() [(0, 0, 0), (2, 1, 0)]
Special Functions: __init__
Class: Point
Input:
self, center, [size=1]) |
Functions: bounding_box,
jmol_repr,
obj_repr,
tachyon_repr
Special Functions: __init__
See About this document... for information on suggesting changes.