diff --git a/mathics/builtin/drawing/plot_plot3d.py b/mathics/builtin/drawing/plot_plot3d.py index 4dced462a..bf3317f50 100644 --- a/mathics/builtin/drawing/plot_plot3d.py +++ b/mathics/builtin/drawing/plot_plot3d.py @@ -111,6 +111,8 @@ def eval( if isinstance(self, ParametricPlot3D) and len(plot_options.ranges) == 1: # ParametricPlot3D with one independent variable generating a curve default_plot_points = (1000,) + elif isinstance(self, ContourPlot3D): + default_plot_points = (50, 50, 50) elif plot.use_vectorized_plot: default_plot_points = (200, 200) else: @@ -235,6 +237,39 @@ class ContourPlot(_Plot3D): graphics_class = Graphics +class ContourPlot3D(_Plot3D): + """ + :Isosurface: https://en.wikipedia.org/wiki/Isosurface ( + :WMA link: https://reference.wolfram.com/language/ref/ContourPlot3D.html) +
+
'ContourPlot3D'[$f(x,y,z)$, {$x$, $x_{min}$, $x_{max}$}, {$y$, $y_{min}$, $y_{max}$, {$y$, $y_{min}$, $y_{max}$}] +
creates a three-dimensional contour plot of $f(x,y,z)$ over the specified region on $x$, $y$, and $z$. + + See :Drawing Option and Option Values: + /doc/reference-of-built-in-symbols/graphics-and-drawing/drawing-options-and-option-values + for a list of Plot options. +
+ + >> ContourPlot3D[x ^ 2 + y ^ 2 - z ^ 2, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] + = ContourPlot3D[x ^ 2 + y ^ 2 - z ^ 2, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] + + Multiple isosurfaces (3d contours) of a second degree equation form conical suraces, hyperboloids in this case. + """ + + requires = ["skimage"] + summary_text = "creates a 3d contour plot" + expected_args = 4 + options = _Plot3D.options3d | { + "Contours": "Automatic", + "BoxRatios": "{1,1,1}", + "Mesh": "None", + } + # TODO: other options? + + many_functions = False + graphics_class = Graphics3D + + class DensityPlot(_Plot3D): """ :heat map:https://en.wikipedia.org/wiki/Heat_map (:WMA link: https://reference.wolfram.com/language/ref/DensityPlot.html) diff --git a/mathics/eval/drawing/colors.py b/mathics/eval/drawing/colors.py index 3c6f6f010..88ca209ef 100644 --- a/mathics/eval/drawing/colors.py +++ b/mathics/eval/drawing/colors.py @@ -181,9 +181,11 @@ def gradient_palette( ] -def palette_color_directive(palette, i): +def palette_color_directive(palette, i, opacity=None): """returns a directive in a form suitable for GraphicsGenerator.add_directives""" """ for setting the color of an entire entity such as a line or surface """ rgb = palette[i % len(palette)] rgb = [c / 255.0 for c in rgb] + if opacity is not None: + rgb.append(opacity) return [SymbolRGBColor, *rgb] diff --git a/mathics/eval/drawing/plot3d.py b/mathics/eval/drawing/plot3d.py index c603902bc..9e7596cfe 100644 --- a/mathics/eval/drawing/plot3d.py +++ b/mathics/eval/drawing/plot3d.py @@ -515,6 +515,13 @@ def eval_ContourPlot( return None +def eval_ContourPlot3D( + plot_options, + evaluation: Evaluation, +): + return None + + def eval_ParametricPlot3D( plot_options, evaluation: Evaluation, diff --git a/mathics/eval/drawing/plot3d_vectorized.py b/mathics/eval/drawing/plot3d_vectorized.py index 0074eb7dd..c89ca439a 100644 --- a/mathics/eval/drawing/plot3d_vectorized.py +++ b/mathics/eval/drawing/plot3d_vectorized.py @@ -14,6 +14,7 @@ from mathics.core.systemsymbols import ( SymbolAbsoluteThickness, SymbolEqual, + SymbolFull, SymbolNone, SymbolRGBColor, SymbolSubtract, @@ -222,6 +223,33 @@ def emit(graphics, i, xyzs, _, quads): return make_surfaces(plot_options, evaluation, dim=2, is_complex=False, emit=emit) +def equations_to_contours(plot_options): + """ + For contour plots, convert functions of the form f==g to f-g, + and adjust contours to [0] and disable background + """ + for i, f in enumerate(plot_options.functions): + if hasattr(f, "head") and f.head == SymbolEqual: + f = Expression(SymbolSubtract, *f.elements[0:2]) + plot_options.functions[i] = f + plot_options.contours = [0] + plot_options.background = False + + +def choose_contour_levels(plot_options, vmin, vmax, default): + levels = plot_options.contours + if isinstance(levels, str): + # TODO: need to pick "nice" number so levels have few digits + # an odd number ensures there is a contour at 0 if range is balanced + levels = default + if isinstance(levels, int): + # computed contour levels have equal distance between them, + # and half that between first/last contours and vmin/vmax + dv = (vmax - vmin) / levels + levels = vmin + np.arange(levels) * dv + dv / 2 + return levels + + @Timer("eval_ContourPlot") def eval_ContourPlot( plot_options, @@ -230,21 +258,14 @@ def eval_ContourPlot( import skimage.measure # whether to show a background similar to density plot, except quantized - background = len(plot_options.functions) == 1 - contour_levels = plot_options.contours + plot_options.background = len(plot_options.functions) == 1 - # convert fs of the form a==b to a-b, inplicit contour level 0 - plot_options.functions = list(plot_options.functions) # so we can modify it - for i, f in enumerate(plot_options.functions): - if hasattr(f, "head") and f.head == SymbolEqual: - f = Expression(SymbolSubtract, *f.elements[0:2]) - plot_options.functions[i] = f - contour_levels = [0] - background = False + # adjust functions, contours, and background for functions of the form f==g + equations_to_contours(plot_options) def emit(graphics, i, xyzs, _, quads): # set line color - if background: + if plot_options.background: # showing a background, so just black lines color_directive = [SymbolRGBColor, 0, 0, 0] else: @@ -259,17 +280,8 @@ def emit(graphics, i, xyzs, _, quads): zs = xyzs[:, 2] # this is a linear list matching with quads # process contour_levels - levels = contour_levels zmin, zmax = np.min(zs), np.max(zs) - if isinstance(levels, str): - # TODO: need to pick "nice" number so levels have few digits - # an odd number ensures there is a contour at 0 if range is balanced - levels = 9 - if isinstance(levels, int): - # computed contour levels have equal distance between them, - # and half that between first/last contours and zmin/zmax - dz = (zmax - zmin) / levels - levels = zmin + np.arange(levels) * dz + dz / 2 + levels = choose_contour_levels(plot_options, zmin, zmax, default=9) # one contour line per contour level for level in levels: @@ -285,7 +297,7 @@ def emit(graphics, i, xyzs, _, quads): graphics.add_linexyzs(segment) # background is solid colors between contour lines - if background: + if plot_options.background: with Timer("contour background"): # use masks and fancy indexing to assign (lo+hi)/2 to all zs between lo and hi zs[zs <= levels[0]] = zmin @@ -301,6 +313,81 @@ def emit(graphics, i, xyzs, _, quads): return make_surfaces(plot_options, evaluation, dim=2, is_complex=False, emit=emit) +@Timer("eval_ContourPlot3D") +def eval_ContourPlot3D( + plot_options, + evaluation: Evaluation, +): + import skimage.measure + + # adjust functions, contours, and background for functions of the form f==g + equations_to_contours(plot_options) + + # pull out options + _, xmin, xmax = plot_options.ranges[0] + _, ymin, ymax = plot_options.ranges[1] + _, zmin, zmax = plot_options.ranges[2] + nx, ny, nz = plot_options.plot_points + names = [strip_context(str(r[0])) for r in plot_options.ranges] + + # compile the functions + with Timer("compile"): + compiled_functions = compile_exprs(evaluation, plot_options.functions, names) + + # construct (nx,ny,nz) grid + xs = np.linspace(xmin, xmax, nx) + ys = np.linspace(ymin, ymax, ny) + zs = np.linspace(zmin, zmax, nz) + xs, ys, zs = np.meshgrid(xs, ys, zs) + + # just one function + function = compiled_functions[0] + + # compute function values fs over the grid + with Timer("compute fs"): + fs = function(**{n: v for n, v in zip(names, [xs, ys, zs])}) + + # process contour_levels + fmin, fmax = np.min(fs), np.max(fs) + levels = choose_contour_levels(plot_options, fmin, fmax, default=7) + + # find contour for each level and emit it + graphics = GraphicsGenerator(dim=3) + for i, level in enumerate(levels): + color_directive = palette_color_directive(palette3, i) + graphics.add_directives(color_directive) + + # find contour for this level + with Timer("3d contours"): + verts, faces, normals, values = skimage.measure.marching_cubes(fs, level) + verts[:, (0, 1)] = verts[:, (1, 0)] # skimage bug? + + # marching_cubes gives back coordinates relative to grid unit, so rescale to x, y, z + offset = [xmin, ymin, zmin] + scale = [ + (xmax - xmin) / (nx - 1), + (ymax - ymin) / (ny - 1), + (zmax - zmin) / (nz - 1), + ] + verts = np.array(offset) + verts * np.array(scale) + + # WL is 1-based + faces += 1 + + # emit faces as GraphicsComplex + graphics.add_complex(verts, lines=None, polys=faces, colors=None) + + # emit mesh as GraphicsComplex + # TODO: this should share vertices with previous GraphicsComplex + if plot_options.mesh is SymbolFull: + # TODO: each segment emitted twice - is there reasonable way to fix? + lines = np.array([faces[:, [0, 1]], faces[:, [1, 2]], faces[:, [2, 0]]]) + graphics.add_directives([SymbolRGBColor, 0, 0, 0]) + graphics.add_complex(verts, lines=lines, polys=None, colors=None) + + return graphics + + @Timer("complex colors") def complex_colors(zs, s=None): # hue depends on phase diff --git a/test/builtin/drawing/test_plot_detail.py b/test/builtin/drawing/test_plot_detail.py index 416f60fc8..c4ffe31ff 100644 --- a/test/builtin/drawing/test_plot_detail.py +++ b/test/builtin/drawing/test_plot_detail.py @@ -370,7 +370,7 @@ def test_yaml(parms): one_test(**parms) -def do_test_all(fns): +def do_test_all(fns, names=None): # several of these tests failed on pyodide due to apparent differences # in numpy (and/or the blas library backing it) between pyodide and other platforms # including numerical instability, different data types (integer vs real) @@ -378,7 +378,8 @@ def do_test_all(fns): # simpler than these doc_tests if not pyodide: for parms in all_yaml_tests_generator(fns): - one_test(**parms) + if not names or parms["name"] in names: + one_test(**parms) if __name__ == "__main__": @@ -391,7 +392,14 @@ def do_test_all(fns): UPDATE_MODE = args.update try: - do_test_all(args.files) + if args.files: + for fn in args.files: + split = fn.split(":") + fn = split[0] + names = split[1].split(",") if len(split) > 1 else None + do_test_all([fn], names) + else: + do_test_all(YAML_TESTS) except AssertionError as oops: print(oops) print("FAIL") diff --git a/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-hyperboloids-vec.txt b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-hyperboloids-vec.txt new file mode 100644 index 000000000..29130b64c --- /dev/null +++ b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-hyperboloids-vec.txt @@ -0,0 +1,348 @@ +System`Graphics3D + System`List + System`RGBColor + System`Real 1.0 + System`Real 0.690196 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 1216×3] + [[-0.17638475 -0.42857143 -1. ] + [-0.14285714 -0.44076332 -1. ] + [-0.14285714 -0.42857143 -0.99441206] + ... + [ 0.10204082 0.45189511 1. ] + [ 0.14285714 0.44076336 -1. ] + [ 0.14285714 0.44076336 1. ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 2252×3] + [[ 3 2 1] + [ 6 5 4] + [ 2 3 7] + ... + [1194 1214 1192] + [1215 1196 1193] + [1197 1216 1194]] + System`RGBColor + System`Real 0.392157 + System`Real 0.560784 + System`Real 1.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 4544×3] + [[-0.09912538 -0.79591837 -1. ] + [-0.06122449 -0.79970846 -1. ] + [-0.06122449 -0.79591837 -0.99684159] + ... + [ 0.02040816 0.80174925 1. ] + [ 0.06122449 0.79970846 -1. ] + [ 0.06122449 0.79970846 1. ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 8764×3] + [[ 3 2 1] + [ 6 5 4] + [ 2 3 7] + ... + [4524 4542 4522] + [4543 4526 4523] + [4527 4544 4524]] + System`RGBColor + System`Real 0.862745 + System`Real 0.14902 + System`Real 0.498039 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 9528×3] + [[-0.38950437 -0.95918367 -1. ] + [-0.3877551 -0.95991254 -1. ] + [-0.3877551 -0.95918367 -0.99927114] + ... + [ 0.34693878 0.97521864 1. ] + [ 0.3877551 0.95991251 -1. ] + [ 0.3877551 0.95991251 1. ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 18656×3] + [[ 3 2 1] + [ 6 5 4] + [ 2 3 7] + ... + [9450 9526 9448] + [9527 9452 9449] + [9453 9528 9450]] + System`RGBColor + System`Real 0.196078 + System`Real 0.588235 + System`Real 0.54902 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 10040×3] + [[-0.76154672 -0.95918367 -1. ] + [-0.75510204 -0.96428571 -1. ] + [-0.75510204 -0.95918367 -0.99489796] + ... + [ 0.71428571 0.99489796 1. ] + [ 0.75510204 0.96428571 -1. ] + [ 0.75510204 0.96428571 1. ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 19568×3] + [[ 3 2 1] + [ 6 5 4] + [ 2 3 7] + ... + [ 9848 10038 9844] + [10039 9850 9846] + [ 9851 10040 9848]] + System`RGBColor + System`Real 0.470588 + System`Real 0.368627 + System`Real 0.941176 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 7256×3] + [[-0.95918367 -1. -0.99562683] + [-0.95918367 -0.96355684 -0.95918367] + [-0.96355684 -0.95918367 -0.95918367] + ... + [ 0.96355687 1. -1. ] + [ 0.96355687 1. 1. ] + [ 1. 0.96355687 1. ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 13840×3] + [[ 3 2 1] + [ 3 1 4] + [ 5 3 4] + ... + [6808 7255 6806] + [7255 7252 6806] + [7252 7251 6806]] + System`RGBColor + System`Real 0.996078 + System`Real 0.380392 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 2504×3] + [[-1. -1. -0.80174927] + [-0.9951409 -1. -0.79591837] + [-1. -0.9951409 -0.79591837] + ... + [ 0.99514085 1. 0.79591837] + [ 1. 0.99514085 0.79591837] + [ 1. 1. 0.80174925]] + System`Polygon + System`NumericArray NumericArray[Integer*, 4528×3] + [[ 3 2 1] + [ 2 3 4] + [ 4 3 5] + ... + [2503 2502 2501] + [2501 2502 2500] + [2503 2504 2502]] + System`RGBColor + System`Real 0.0 + System`Real 0.447059 + System`Real 0.698039 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 464×3] + [[-1. -1. -0.46302675] + [-0.98420798 -1. -0.42857143] + [-1. -0.98420798 -0.42857143] + ... + [ 0.98420793 1. 0.42857143] + [ 1. 0.98420793 0.42857143] + [ 1. 1. 0.46302671]] + System`Polygon + System`NumericArray NumericArray[Integer*, 704×3] + [[ 3 2 1] + [ 2 3 4] + [ 4 3 5] + ... + [463 462 461] + [461 462 460] + [463 464 462]] + System`Rule + System`AlignmentPoint + System`Center + System`Rule + System`AspectRatio + System`Integer 1 + System`Rule + System`Axes + System`True + System`Rule + System`AxesEdge + System`Automatic + System`Rule + System`AxesLabel + System`None + System`Rule + System`AxesOrigin + System`Automatic + System`Rule + System`AxesStyle + System`List + System`Rule + System`Background + System`Automatic + System`Rule + System`BaseStyle + System`List + System`Rule + System`BaselinePosition + System`Automatic + System`Rule + System`BoxRatios + System`List + System`Integer 1 + System`Integer 1 + System`Integer 1 + System`Rule + System`BoxStyle + System`List + System`Rule + System`Boxed + System`True + System`Rule + System`ClipPlanes + System`None + System`Rule + System`ClipPlanesStyle + System`Automatic + System`Rule + System`ContentSelectable + System`Automatic + System`Rule + System`ControllerLinking + System`False + System`Rule + System`ControllerPath + System`Automatic + System`Rule + System`CoordinatesToolOptions + System`Automatic + System`Rule + System`Epilog + System`List + System`Rule + System`FaceGrids + System`None + System`Rule + System`FaceGridsStyle + System`List + System`Rule + System`FormatType + System`TraditionalForm + System`Rule + System`Frame + System`False + System`Rule + System`FrameLabel + System`None + System`Rule + System`FrameStyle + System`List + System`Rule + System`FrameTicks + System`Automatic + System`Rule + System`FrameTicksStyle + System`List + System`Rule + System`GridLines + System`None + System`Rule + System`GridLinesStyle + System`List + System`Rule + System`ImageMargins + System`Real 0.0 + System`Rule + System`ImagePadding + System`All + System`Rule + System`ImageSize + System`Automatic + System`Rule + System`LabelStyle + System`List + System`Rule + System`Lighting + System`Automatic + System`Rule + System`LogPlot + System`False + System`Rule + System`Method + System`Automatic + System`Rule + System`PlotLabel + System`None + System`Rule + System`PlotRange + System`List + System`List + System`Real -1.0 + System`Real 1.0 + System`List + System`Real -1.0 + System`Real 1.0 + System`List + System`Real -1.0 + System`Real 1.0 + System`Rule + System`PlotRangeClipping + System`False + System`Rule + System`PlotRangePadding + System`Automatic + System`Rule + System`PlotRegion + System`Automatic + System`Rule + System`PreserveImageOptions + System`Automatic + System`Rule + System`Prolog + System`List + System`Rule + System`RotateLabel + System`True + System`Rule + System`RotationAction + System`Fit + System`Rule + System`SphericalRegion + System`Automatic + System`Rule + System`Ticks + System`Automatic + System`Rule + System`TicksStyle + System`List + System`Rule + System`TouchscreenAutoZoom + System`False + System`Rule + System`ViewAngle + System`Automatic + System`Rule + System`ViewCenter + System`Automatic + System`Rule + System`ViewMatrix + System`Automatic + System`Rule + System`ViewPoint + System`List + System`Real 1.3 + System`Real -2.4 + System`Real 2.0 + System`Rule + System`ViewProjection + System`Automatic + System`Rule + System`ViewRange + System`All + System`Rule + System`ViewVector + System`Automatic + System`Rule + System`ViewVertical + System`List + System`Integer 0 + System`Integer 0 + System`Integer 1 diff --git a/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-mesh-vec.txt b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-mesh-vec.txt new file mode 100644 index 000000000..d08910d55 --- /dev/null +++ b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-mesh-vec.txt @@ -0,0 +1,254 @@ +System`Graphics3D + System`List + System`RGBColor + System`Real 1.0 + System`Real 0.690196 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 1656×3] + [[-0.36842105 -0.91520468 -0.15789474] + [-0.41447368 -0.89473684 -0.15789474] + [-0.36842105 -0.89473684 -0.25 ] + ... + [ 0.36842105 0.92690056 -0.05263158] + [ 0.36842105 0.92690056 0.05263158] + [ 0.36842105 0.9152047 0.15789474]] + System`Polygon + System`NumericArray NumericArray[Integer*, 3308×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [1655 1595 1597] + [1655 1597 1656] + [1656 1597 1585]] + System`RGBColor + System`Integer 0 + System`Integer 0 + System`Integer 0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 1656×3] + [[-0.36842105 -0.91520468 -0.15789474] + [-0.41447368 -0.89473684 -0.15789474] + [-0.36842105 -0.89473684 -0.25 ] + ... + [ 0.36842105 0.92690056 -0.05263158] + [ 0.36842105 0.92690056 0.05263158] + [ 0.36842105 0.9152047 0.15789474]] + System`Line + System`NumericArray NumericArray[Integer*, 3×3308×2] + [[[ 3 2] + [ 5 4] + [ 5 1] + ... + [1655 1595] + [1655 1597] + [1656 1597]] + + [[ 2 1] + [ 4 1] + [ 1 2] + ... + [1595 1597] + [1597 1656] + [1597 1585]] + + [[ 1 3] + [ 1 5] + [ 2 5] + ... + [1597 1655] + [1656 1655] + [1585 1656]]] + System`Rule + System`AlignmentPoint + System`Center + System`Rule + System`AspectRatio + System`Integer 1 + System`Rule + System`Axes + System`True + System`Rule + System`AxesEdge + System`Automatic + System`Rule + System`AxesLabel + System`None + System`Rule + System`AxesOrigin + System`Automatic + System`Rule + System`AxesStyle + System`List + System`Rule + System`Background + System`Automatic + System`Rule + System`BaseStyle + System`List + System`Rule + System`BaselinePosition + System`Automatic + System`Rule + System`BoxRatios + System`List + System`Integer 1 + System`Integer 1 + System`Integer 1 + System`Rule + System`BoxStyle + System`List + System`Rule + System`Boxed + System`True + System`Rule + System`ClipPlanes + System`None + System`Rule + System`ClipPlanesStyle + System`Automatic + System`Rule + System`ContentSelectable + System`Automatic + System`Rule + System`ControllerLinking + System`False + System`Rule + System`ControllerPath + System`Automatic + System`Rule + System`CoordinatesToolOptions + System`Automatic + System`Rule + System`Epilog + System`List + System`Rule + System`FaceGrids + System`None + System`Rule + System`FaceGridsStyle + System`List + System`Rule + System`FormatType + System`TraditionalForm + System`Rule + System`Frame + System`False + System`Rule + System`FrameLabel + System`None + System`Rule + System`FrameStyle + System`List + System`Rule + System`FrameTicks + System`Automatic + System`Rule + System`FrameTicksStyle + System`List + System`Rule + System`GridLines + System`None + System`Rule + System`GridLinesStyle + System`List + System`Rule + System`ImageMargins + System`Real 0.0 + System`Rule + System`ImagePadding + System`All + System`Rule + System`ImageSize + System`Automatic + System`Rule + System`LabelStyle + System`List + System`Rule + System`Lighting + System`Automatic + System`Rule + System`LogPlot + System`False + System`Rule + System`Method + System`Automatic + System`Rule + System`PlotLabel + System`None + System`Rule + System`PlotRange + System`List + System`List + System`Real -1.0 + System`Real 1.0 + System`List + System`Real -1.0 + System`Real 1.0 + System`List + System`Real -1.0 + System`Real 1.0 + System`Rule + System`PlotRangeClipping + System`False + System`Rule + System`PlotRangePadding + System`Automatic + System`Rule + System`PlotRegion + System`Automatic + System`Rule + System`PreserveImageOptions + System`Automatic + System`Rule + System`Prolog + System`List + System`Rule + System`RotateLabel + System`True + System`Rule + System`RotationAction + System`Fit + System`Rule + System`SphericalRegion + System`Automatic + System`Rule + System`Ticks + System`Automatic + System`Rule + System`TicksStyle + System`List + System`Rule + System`TouchscreenAutoZoom + System`False + System`Rule + System`ViewAngle + System`Automatic + System`Rule + System`ViewCenter + System`Automatic + System`Rule + System`ViewMatrix + System`Automatic + System`Rule + System`ViewPoint + System`List + System`Real 1.3 + System`Real -2.4 + System`Real 2.0 + System`Rule + System`ViewProjection + System`Automatic + System`Rule + System`ViewRange + System`All + System`Rule + System`ViewVector + System`Automatic + System`Rule + System`ViewVertical + System`List + System`Integer 0 + System`Integer 0 + System`Integer 1 diff --git a/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-sphere-multi-vec.txt b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-sphere-multi-vec.txt new file mode 100644 index 000000000..be2950e9d --- /dev/null +++ b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-sphere-multi-vec.txt @@ -0,0 +1,504 @@ +System`Graphics3D + System`List + System`RGBColor + System`Real 1.0 + System`Real 0.690196 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 2156×3] + [[ 0.01020408 -0.58166669 -0.03061224] + [ 0.00816283 -0.58163265 -0.03061224] + [ 0.01020408 -0.58163265 -0.03095241] + ... + [ 0.25510204 0.52271356 0.03061224] + [ 0.01020408 0.58166675 -0.03061224] + [ 0.01020408 0.58166675 0.03061224]] + System`Polygon + System`NumericArray NumericArray[Integer*, 4270×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [2155 2120 2122] + [2155 2122 2156] + [2156 2122 2114]] + System`RGBColor + System`Real 0.392157 + System`Real 0.560784 + System`Real 1.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 5168×3] + [[-0.31632653 -0.95159439 -0.09183673] + [-0.32393319 -0.94897959 -0.09183673] + [-0.31632653 -0.94897959 -0.11275513] + ... + [ 0.29591837 0.96179838 0.03061224] + [ 0.29591837 0.95797185 0.09183673] + [ 0.29591837 0.95031878 0.15306122]] + System`Polygon + System`NumericArray NumericArray[Integer*, 10222×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [5167 4999 5001] + [5167 5001 5168] + [5168 5001 4985]] + System`RGBColor + System`Real 0.862745 + System`Real 0.14902 + System`Real 0.498039 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 7952×3] + [[-0.31632653 -1.25712667 -0.09183673] + [-0.3240569 -1.25510204 -0.09183673] + [-0.31632653 -1.25510204 -0.1130953 ] + ... + [ 0.29591837 1.26490122 0.03061224] + [ 0.29591837 1.26198578 0.09183673] + [ 0.29591837 1.2561549 0.15306122]] + System`Polygon + System`NumericArray NumericArray[Integer*, 15742×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [7951 7770 7772] + [7951 7772 7952] + [7952 7772 7754]] + System`RGBColor + System`Real 0.196078 + System`Real 0.588235 + System`Real 0.54902 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 9972×3] + [[-0.52040816 -1.44369333 -0.09183673] + [-0.53376972 -1.43877551 -0.09183673] + [-0.52040816 -1.43877551 -0.15085006] + ... + [ 0.5 1.45333053 0.03061224] + [ 0.5 1.45077943 0.09183673] + [ 0.5 1.44567747 0.15306122]] + System`Polygon + System`NumericArray NumericArray[Integer*, 19496×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [9965 9685 9686] + [9965 9686 9966] + [9966 9686 9671]] + System`RGBColor + System`Real 0.470588 + System`Real 0.368627 + System`Real 0.941176 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 7796×3] + [[-0.96938776 -1.44060375 -0.15306122] + [-0.97210183 -1.43877551 -0.15306122] + [-0.96938776 -1.43877551 -0.16768712] + ... + [ 0.5 1.48397103 0.76530612] + [ 0.5 1.5 0.73324842] + [ 0.5 1.45080792 0.82653061]] + System`Polygon + System`NumericArray NumericArray[Integer*, 14968×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [7787 7794 7796] + [7796 7524 7518] + [7796 7518 7790]] + System`RGBColor + System`Real 0.996078 + System`Real 0.380392 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 5436×3] + [[-1.25510204 -1.44630104 -0.21428571] + [-1.26377145 -1.43877551 -0.21428571] + [-1.25510204 -1.43877551 -0.25943885] + ... + [ 0.5 1.5 -1.10111487] + [ 0.5 1.47634646 1.13265306] + [ 0.5 1.5 1.10111478]] + System`Polygon + System`NumericArray NumericArray[Integer*, 10152×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [5432 5435 5168] + [5429 5435 5432] + [5432 5168 5162]] + System`RGBColor + System`Real 0.0 + System`Real 0.447059 + System`Real 0.698039 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 2952×3] + [[-1.45918367 -1.44916378 -0.39795918] + [-1.46950031 -1.43877551 -0.39795918] + [-1.45918367 -1.43877551 -0.43357635] + ... + [ 0.5 1.49678281 1.37755102] + [ 0.5 1.5 1.37404142] + [ 0.49014313 1.5 1.37755102]] + System`Polygon + System`NumericArray NumericArray[Integer*, 5096×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [2950 2659 2945] + [2659 2660 2945] + [2945 2660 2654]] + System`RGBColor + System`Real 1.0 + System`Real 0.690196 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 1112×3] + [[-1.45918367 -1.46449833 -0.8877551 ] + [-1.48472912 -1.43877551 -0.8877551 ] + [-1.45918367 -1.43877551 -0.92891168] + ... + [-0.76530612 1.5 1.49227617] + [-0.75006991 1.5 -1.5 ] + [-0.75006991 1.5 1.5 ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 1868×3] + [[ 3 2 1] + [ 1 2 4] + [ 1 4 5] + ... + [1109 1106 1110] + [1108 1111 1107] + [1110 1112 1109]] + System`RGBColor + System`Real 0.392157 + System`Real 0.560784 + System`Real 1.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 380×3] + [[-1.45918367 -1.47728172 -1.19387755] + [-1.49742435 -1.43877551 -1.19387755] + [-1.45918367 -1.43877551 -1.24008494] + ... + [-1.13265306 1.5 1.48465137] + [-1.11237584 1.5 -1.5 ] + [-1.11237584 1.5 1.5 ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 572×3] + [[ 3 2 1] + [ 1 2 4] + [ 1 4 5] + ... + [377 374 378] + [376 379 375] + [378 380 377]] + System`RGBColor + System`Real 0.862745 + System`Real 0.14902 + System`Real 0.498039 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 52×3] + [[-1.45918367 -1.48751413 -1.43877551] + [-1.5 -1.44641436 -1.43877551] + [-1.5 -1.43877551 -1.44641436] + [-1.45918367 -1.43877551 -1.48751413] + [-1.5 -1.5 -1.38286007] + [-1.45918367 -1.5 -1.42574678] + [-1.5 -1.44641436 1.43877551] + [-1.45918367 -1.5 1.42574676] + [-1.45918367 -1.48751413 1.43877551] + [-1.5 -1.5 1.38286014] + [-1.45918367 -1.43877551 1.48751403] + [-1.5 -1.43877551 1.44641432] + [-1.44643213 -1.43877551 -1.5 ] + [-1.41836735 -1.46625565 -1.5 ] + [-1.41836735 -1.5 -1.46625565] + [-1.44643213 -1.5 -1.43877551] + [-1.44643213 -1.5 1.43877551] + [-1.41836735 -1.5 1.46625558] + [-1.41836735 -1.46625565 1.5 ] + [-1.44643213 -1.43877551 1.5 ] + [-1.38289883 -1.5 -1.5 ] + [-1.38289883 -1.5 1.5 ] + [-1.45918367 -1.42574678 -1.5 ] + [-1.5 -1.38286007 -1.5 ] + [-1.5 -1.38286007 1.5 ] + [-1.45918367 -1.42574678 1.5 ] + [-1.45918367 1.43877551 -1.48751413] + [-1.5 1.38286014 -1.5 ] + [-1.5 1.43877551 -1.44641436] + [-1.45918367 1.42574676 -1.5 ] + [-1.45918367 1.42574676 1.5 ] + [-1.5 1.43877551 1.44641432] + [-1.5 1.38286014 1.5 ] + [-1.45918367 1.43877551 1.48751403] + [-1.44643213 1.43877551 -1.5 ] + [-1.44643213 1.43877551 1.5 ] + [-1.5 1.44641432 -1.43877551] + [-1.45918367 1.48751403 -1.43877551] + [-1.45918367 1.5 -1.42574678] + [-1.5 1.5 -1.38286007] + [-1.45918367 1.48751403 1.43877551] + [-1.5 1.5 1.38286014] + [-1.5 1.44641432 1.43877551] + [-1.45918367 1.5 1.42574676] + [-1.41836735 1.5 -1.46625565] + [-1.41836735 1.46625558 -1.5 ] + [-1.44643213 1.5 -1.43877551] + [-1.44643213 1.5 1.43877551] + [-1.41836735 1.46625558 1.5 ] + [-1.41836735 1.5 1.46625558] + [-1.38289883 1.5 -1.5 ] + [-1.38289883 1.5 1.5 ]] + System`Polygon + System`NumericArray NumericArray[Integer*, 52×3] + [[ 3 2 1] + [ 3 1 4] + [ 6 1 5] + [ 5 1 2] + [ 9 8 7] + [ 7 8 10] + [ 7 12 11] + [ 7 11 9] + [14 13 4] + [14 4 1] + [15 14 1] + [16 15 1] + [16 1 6] + [ 9 17 8] + [20 19 18] + [20 18 17] + [11 20 17] + [ 9 11 17] + [21 14 15] + [19 22 18] + [ 4 23 3] + [ 3 23 24] + [26 11 25] + [25 11 12] + [13 23 4] + [26 20 11] + [29 28 27] + [27 28 30] + [33 32 31] + [31 32 34] + [30 35 27] + [34 36 31] + [27 38 37] + [27 37 29] + [40 37 39] + [39 37 38] + [43 42 41] + [41 42 44] + [41 34 32] + [41 32 43] + [46 45 35] + [35 45 27] + [45 47 27] + [47 38 27] + [38 47 39] + [44 48 41] + [48 50 49] + [48 49 36] + [41 48 36] + [34 41 36] + [46 51 45] + [50 52 49]] + System`Rule + System`AlignmentPoint + System`Center + System`Rule + System`AspectRatio + System`Integer 1 + System`Rule + System`Axes + System`True + System`Rule + System`AxesEdge + System`Automatic + System`Rule + System`AxesLabel + System`None + System`Rule + System`AxesOrigin + System`Automatic + System`Rule + System`AxesStyle + System`List + System`Rule + System`Background + System`Automatic + System`Rule + System`BaseStyle + System`List + System`Rule + System`BaselinePosition + System`Automatic + System`Rule + System`BoxRatios + System`List + System`Integer 1 + System`Integer 1 + System`Integer 1 + System`Rule + System`BoxStyle + System`List + System`Rule + System`Boxed + System`True + System`Rule + System`ClipPlanes + System`None + System`Rule + System`ClipPlanesStyle + System`Automatic + System`Rule + System`ContentSelectable + System`Automatic + System`Rule + System`ControllerLinking + System`False + System`Rule + System`ControllerPath + System`Automatic + System`Rule + System`CoordinatesToolOptions + System`Automatic + System`Rule + System`Epilog + System`List + System`Rule + System`FaceGrids + System`None + System`Rule + System`FaceGridsStyle + System`List + System`Rule + System`FormatType + System`TraditionalForm + System`Rule + System`Frame + System`False + System`Rule + System`FrameLabel + System`None + System`Rule + System`FrameStyle + System`List + System`Rule + System`FrameTicks + System`Automatic + System`Rule + System`FrameTicksStyle + System`List + System`Rule + System`GridLines + System`None + System`Rule + System`GridLinesStyle + System`List + System`Rule + System`ImageMargins + System`Real 0.0 + System`Rule + System`ImagePadding + System`All + System`Rule + System`ImageSize + System`Automatic + System`Rule + System`LabelStyle + System`List + System`Rule + System`Lighting + System`Automatic + System`Rule + System`LogPlot + System`False + System`Rule + System`Method + System`Automatic + System`Rule + System`PlotLabel + System`None + System`Rule + System`PlotRange + System`List + System`List + System`Real -1.5 + System`Real 1.5 + System`List + System`Real -1.5 + System`Real 1.5 + System`List + System`Real -1.5 + System`Real 1.5 + System`Rule + System`PlotRangeClipping + System`False + System`Rule + System`PlotRangePadding + System`Automatic + System`Rule + System`PlotRegion + System`Automatic + System`Rule + System`PreserveImageOptions + System`Automatic + System`Rule + System`Prolog + System`List + System`Rule + System`RotateLabel + System`True + System`Rule + System`RotationAction + System`Fit + System`Rule + System`SphericalRegion + System`Automatic + System`Rule + System`Ticks + System`Automatic + System`Rule + System`TicksStyle + System`List + System`Rule + System`TouchscreenAutoZoom + System`False + System`Rule + System`ViewAngle + System`Automatic + System`Rule + System`ViewCenter + System`Automatic + System`Rule + System`ViewMatrix + System`Automatic + System`Rule + System`ViewPoint + System`List + System`Real 1.3 + System`Real -2.4 + System`Real 2.0 + System`Rule + System`ViewProjection + System`Automatic + System`Rule + System`ViewRange + System`All + System`Rule + System`ViewVector + System`Automatic + System`Rule + System`ViewVertical + System`List + System`Integer 0 + System`Integer 0 + System`Integer 1 diff --git a/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-sphere-vec.txt b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-sphere-vec.txt new file mode 100644 index 000000000..e58a0f62a --- /dev/null +++ b/test/builtin/drawing/test_plot_detail_ref/vec-contourplot3d-sphere-vec.txt @@ -0,0 +1,216 @@ +System`Graphics3D + System`List + System`RGBColor + System`Real 1.0 + System`Real 0.690196 + System`Real 0.0 + System`GraphicsComplex + System`NumericArray NumericArray[Real*, 5040×3] + [[-0.2755102 -0.94903273 -0.15306122] + [-0.27568023 -0.94897959 -0.15306122] + [-0.2755102 -0.94897959 -0.15334464] + ... + [ 0.2755102 0.96051243 0.03061224] + [ 0.2755102 0.9566859 0.09183673] + [ 0.2755102 0.94903284 0.15306122]] + System`Polygon + System`NumericArray NumericArray[Integer*, 10076×3] + [[ 3 2 1] + [ 5 4 1] + [ 5 1 2] + ... + [5039 4937 4939] + [5039 4939 5040] + [5040 4939 4923]] + System`Rule + System`AlignmentPoint + System`Center + System`Rule + System`AspectRatio + System`Integer 1 + System`Rule + System`Axes + System`True + System`Rule + System`AxesEdge + System`Automatic + System`Rule + System`AxesLabel + System`None + System`Rule + System`AxesOrigin + System`Automatic + System`Rule + System`AxesStyle + System`List + System`Rule + System`Background + System`Automatic + System`Rule + System`BaseStyle + System`List + System`Rule + System`BaselinePosition + System`Automatic + System`Rule + System`BoxRatios + System`List + System`Integer 1 + System`Integer 1 + System`Integer 1 + System`Rule + System`BoxStyle + System`List + System`Rule + System`Boxed + System`True + System`Rule + System`ClipPlanes + System`None + System`Rule + System`ClipPlanesStyle + System`Automatic + System`Rule + System`ContentSelectable + System`Automatic + System`Rule + System`ControllerLinking + System`False + System`Rule + System`ControllerPath + System`Automatic + System`Rule + System`CoordinatesToolOptions + System`Automatic + System`Rule + System`Epilog + System`List + System`Rule + System`FaceGrids + System`None + System`Rule + System`FaceGridsStyle + System`List + System`Rule + System`FormatType + System`TraditionalForm + System`Rule + System`Frame + System`False + System`Rule + System`FrameLabel + System`None + System`Rule + System`FrameStyle + System`List + System`Rule + System`FrameTicks + System`Automatic + System`Rule + System`FrameTicksStyle + System`List + System`Rule + System`GridLines + System`None + System`Rule + System`GridLinesStyle + System`List + System`Rule + System`ImageMargins + System`Real 0.0 + System`Rule + System`ImagePadding + System`All + System`Rule + System`ImageSize + System`Automatic + System`Rule + System`LabelStyle + System`List + System`Rule + System`Lighting + System`Automatic + System`Rule + System`LogPlot + System`False + System`Rule + System`Method + System`Automatic + System`Rule + System`PlotLabel + System`None + System`Rule + System`PlotRange + System`List + System`List + System`Real -1.5 + System`Real 1.5 + System`List + System`Real -1.5 + System`Real 1.5 + System`List + System`Real -1.5 + System`Real 1.5 + System`Rule + System`PlotRangeClipping + System`False + System`Rule + System`PlotRangePadding + System`Automatic + System`Rule + System`PlotRegion + System`Automatic + System`Rule + System`PreserveImageOptions + System`Automatic + System`Rule + System`Prolog + System`List + System`Rule + System`RotateLabel + System`True + System`Rule + System`RotationAction + System`Fit + System`Rule + System`SphericalRegion + System`Automatic + System`Rule + System`Ticks + System`Automatic + System`Rule + System`TicksStyle + System`List + System`Rule + System`TouchscreenAutoZoom + System`False + System`Rule + System`ViewAngle + System`Automatic + System`Rule + System`ViewCenter + System`Automatic + System`Rule + System`ViewMatrix + System`Automatic + System`Rule + System`ViewPoint + System`List + System`Real 1.3 + System`Real -2.4 + System`Real 2.0 + System`Rule + System`ViewProjection + System`Automatic + System`Rule + System`ViewRange + System`All + System`Rule + System`ViewVector + System`Automatic + System`Rule + System`ViewVertical + System`List + System`Integer 0 + System`Integer 0 + System`Integer 1 diff --git a/test/builtin/drawing/vec_tests.yaml b/test/builtin/drawing/vec_tests.yaml index 6025a2a56..91c23e367 100644 --- a/test/builtin/drawing/vec_tests.yaml +++ b/test/builtin/drawing/vec_tests.yaml @@ -24,6 +24,40 @@ vec-contourplot-two-equations: vec-contourplot-one-equation-two-branches: expr: ContourPlot[{a b + Sqrt[a^2 + b^2] == a+b}, {a,-10,10}, {b,-10,10}] # +# ContourPlot3D +# +vec-contourplot3d-sphere: + expr: ' + ContourPlot3D[ + x^2 + y^2 == 1 - z^2, + {x,-1.5,1.5}, {y,-1.5,1.5}, {z,-1.5,1.5} + ] + ' +vec-contourplot3d-sphere-multi: + expr: ' + ContourPlot3D[ + x^2 + y^2 + z^2, + {x,-1.5,0.5}, {y,-1.5,1.5}, {z,-1.5,1.5}, + PlotRange->{{-1.5,1.5},Automatic,Automatic}, + Contours->10 + ] + ' +vec-contourplot3d-hyperboloids: + expr: ' + ContourPlot3D[ + x^2 + y^2 - z^2, + {x,-1,1}, {y,-1,1}, {z,-1,1} + ] + ' +vec-contourplot3d-mesh: + expr: ' + ContourPlot3D[ + x^2 + y^2 + z^2 == 1, + {x,-1,1}, {y,-1,1}, {z,-1,1}, + PlotPoints->20, Mesh->Full + ] + ' +# # ComplexPlot # vec-complexplot-poles-zeros: