Adaptive refinement code for 3d surface plotting#
AUTHOR:
Tom Boothby – Algorithm design, code
Joshua Kantor – Algorithm design
Marshall Hampton – Docstrings and doctests
Todo
Parametrizations (cylindrical, spherical)
Massive optimization
- class sage.plot.plot3d.tri_plot.PlotBlock(left, left_c, top, top_c, right, right_c, bottom, bottom_c)[source]#
Bases:
object
A container class to hold information about spatial blocks.
- class sage.plot.plot3d.tri_plot.SmoothTriangle(a, b, c, da, db, dc, color=0)[source]#
Bases:
Triangle
A class for smoothed triangles.
- class sage.plot.plot3d.tri_plot.Triangle(a, b, c, color=0)[source]#
Bases:
object
A graphical triangle class.
- class sage.plot.plot3d.tri_plot.TriangleFactory[source]#
Bases:
object
- get_colors(list)[source]#
Parameters: list: an iterable collection of values which can be cast into colors – typically an RGB triple, or an RGBA 4-tuple
Returns: a list of single parameters which can be passed into the set_color method of the Triangle or SmoothTriangle objects generated by this factory.
- smooth_triangle(a, b, c, da, db, dc, color=None)[source]#
Parameters:
a, b, c : triples (x,y,z) representing corners on a triangle in 3-space
da, db, dc : triples (dx,dy,dz) representing the normal vector at each point a,b,c
Returns: a SmoothTriangle object with the specified coordinates and normals
- class sage.plot.plot3d.tri_plot.TrianglePlot(triangle_factory, f, min_x__max_x, min_y__max_y, g=None, min_depth=4, max_depth=8, num_colors=None, max_bend=0.3)[source]#
Bases:
object
Recursively plots a function of two variables by building squares of 4 triangles, checking at every stage whether or not each square should be split into four more squares. This way, more planar areas get fewer triangles, and areas with higher curvature get more triangles.
- extrema(list)[source]#
If the num_colors option has been set, this expands the TrianglePlot’s _min and _max attributes to include the minimum and maximum of the argument list.
- interface(n, p, p_c, q, q_c)[source]#
Takes a pair of lists of points, and compares the (n)th coordinate, and “zips” the lists together into one. The “centers”, supplied in p_c and q_c are matched up such that the lists describe triangles whose sides are “perfectly” aligned. This algorithm assumes that p and q start and end at the same point, and are sorted smallest to largest.
- sage.plot.plot3d.tri_plot.crossunit(u, v)[source]#
This function computes triangle normal unit vectors by taking the cross-products of the midpoint-to-corner vectors. It always goes around clockwise so we’re guaranteed to have a positive value near 1 when neighboring triangles are parallel. However – crossunit doesn’t really return a unit vector. It returns the length of the vector to avoid numerical instability when the length is nearly zero – rather than divide by nearly zero, we multiply the other side of the inequality by nearly zero – in general, this should work a bit better because of the density of floating-point numbers near zero.