@@ -23,21 +23,21 @@ def eval_Plot3D(
2323):
2424 graphics = GraphicsGenerator (dim = 3 )
2525
26- for function in plot_options .functions :
27- # pull out plot options
28- _ , xmin , xmax = plot_options .ranges [0 ]
29- _ , ymin , ymax = plot_options .ranges [1 ]
30- nx , ny = plot_options .plotpoints
31- names = [strip_context (str (range [0 ])) for range in plot_options .ranges ]
26+ # pull out plot options
27+ _ , xmin , xmax = plot_options .ranges [0 ]
28+ _ , ymin , ymax = plot_options .ranges [1 ]
29+ nx , ny = plot_options .plotpoints
30+ names = [strip_context (str (range [0 ])) for range in plot_options .ranges ]
31+
32+ # compute (nx, ny) grids of xs and ys for corresponding vertexes
33+ xs = np .linspace (xmin , xmax , nx )
34+ ys = np .linspace (ymin , ymax , ny )
35+ xs , ys = np .meshgrid (xs , ys )
3236
37+ for function in plot_options .functions :
3338 with Timer ("compile" ):
3439 function = plot_compile (evaluation , function , names )
3540
36- # compute (nx, ny) grids of xs and ys for corresponding vertexes
37- xs = np .linspace (xmin , xmax , nx )
38- ys = np .linspace (ymin , ymax , ny )
39- xs , ys = np .meshgrid (xs , ys )
40-
4141 # compute zs from xs and ys using compiled function
4242 with Timer ("compute zs" ):
4343 zs = function (** {str (names [0 ]): xs , str (names [1 ]): ys })
@@ -49,6 +49,10 @@ def eval_Plot3D(
4949 # assert np.all(np.isreal(zs)), "array contains complex values"
5050 zs = np .real (zs )
5151
52+ # if it's a constant, make it a full array
53+ if isinstance (zs , (float ,int ,complex )):
54+ zs = np .full (xs .shape , zs )
55+
5256 with Timer ("stack" ):
5357 # (nx*ny, 3) array of points, to be indexed by quads
5458 xyzs = np .stack ([xs , ys , zs ]).transpose (1 , 2 , 0 ).reshape (- 1 , 3 )
0 commit comments