6.6 Lines, Frames, Spheres, Points, Dots, and Text

Module: sage.plot.plot3d.shapes2

Lines, Frames, Spheres, Points, Dots, and Text

Module-level Functions

avg( a, b)

dot( ['x0', 'y0', 'z0'], ['x1', 'y1', 'z1'])

frame3d( lower_left, upper_right)

Draw a frame in 3d.

frame_labels( lower_left, upper_right, label_lower_left, label_upper_right, [eps=1])

line3d( 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:

points
- a list of at least 2 points
thickness
- (default: 1)
radius
- (default: None)
arrow_head
- (default: False)
color
- a word that describes a color
rgbcolor
- (r,g,b) with r, g, b between 0 and 1 that describes a color
opacity
- (default: 1) if less than 1 then is transparent

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)

point3d( v, [size=1])

Plot a point or list of points in 3d space.

Input:

v
- a point or list of points
size
- (default: 1) size of the point (or points)
color
- a word that describes a color
rgbcolor
- (r,g,b) with r, g, b between 0 and 1 that describes a color
opacity
- (default: 1) if less than 1 then is transparent

sage: sum([point3d((i,i^2,i^3), size=5) for i in range(10)])

ruler( start, end, [ticks=4], [sub_ticks=4], [absolute=False], [snap=False])

ruler_frame( lower_left, upper_right, [ticks=4], [sub_ticks=4])

sphere( [center=(0, 0, 0)], [size=1])

Return a plot of a sphere of radius size centered at $ (x,y,z)$ .

Input:

(x,y,z)
- center (default: (0,0,0)
size
- the radius (default: 1)

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

text3d( txt, ['x', 'y', 'z'])

Display 3d text.

Input:

txt
- some text
(x,y,z)
- position
**kwds
- standard 3d graphics options

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]])

validate_frame_size( size)

Class: Line

class Line
Draw a 3d line joining a sequence of points.

This line has a fixed diameter unaffected by transformations and zooming. It may be smoothed if corner_cutoff < 1.

Input:

points
- list of points to pass through
thickness
- diameter of the line
corner_cutoff
- threshold for smoothing (see the corners() method) this is the minimum cosine between adjacent segments to smooth
arrow_head
- if True make this curve into an arrow

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)
Line( self, points, [thickness=5], [corner_cutoff=0.5], [arrow_head=False])

Functions: bounding_box,$ \,$ corners,$ \,$ jmol_repr,$ \,$ obj_repr,$ \,$ tachyon_repr

corners( 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

class Point
Create a position in 3-space, represented by a sphere of fixed size.

Input:

center
- point (3-tuple)
size
- (default: 1)

Point( 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.