passagemath-plot 10.6.31rc3__cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-plot might be problematic. Click here for more details.

Files changed (82) hide show
  1. passagemath_plot-10.6.31rc3.dist-info/METADATA +172 -0
  2. passagemath_plot-10.6.31rc3.dist-info/RECORD +82 -0
  3. passagemath_plot-10.6.31rc3.dist-info/WHEEL +6 -0
  4. passagemath_plot-10.6.31rc3.dist-info/top_level.txt +2 -0
  5. passagemath_plot.libs/libgfortran-83c28eba.so.5.0.0 +0 -0
  6. passagemath_plot.libs/libgsl-cda90e79.so.28.0.0 +0 -0
  7. passagemath_plot.libs/libopenblasp-r0-6dcb67f9.3.29.so +0 -0
  8. passagemath_plot.libs/libquadmath-2284e583.so.0.0.0 +0 -0
  9. sage/all__sagemath_plot.py +15 -0
  10. sage/ext_data/threejs/animation.css +195 -0
  11. sage/ext_data/threejs/animation.html +85 -0
  12. sage/ext_data/threejs/animation.js +273 -0
  13. sage/ext_data/threejs/fat_lines.js +48 -0
  14. sage/ext_data/threejs/threejs-version.txt +1 -0
  15. sage/ext_data/threejs/threejs_template.html +597 -0
  16. sage/interfaces/all__sagemath_plot.py +1 -0
  17. sage/interfaces/gnuplot.py +196 -0
  18. sage/interfaces/jmoldata.py +208 -0
  19. sage/interfaces/povray.py +56 -0
  20. sage/plot/all.py +42 -0
  21. sage/plot/animate.py +1796 -0
  22. sage/plot/arc.py +504 -0
  23. sage/plot/arrow.py +671 -0
  24. sage/plot/bar_chart.py +205 -0
  25. sage/plot/bezier_path.py +400 -0
  26. sage/plot/circle.py +435 -0
  27. sage/plot/colors.py +1606 -0
  28. sage/plot/complex_plot.cpython-314-x86_64-linux-gnu.so +0 -0
  29. sage/plot/complex_plot.pyx +1446 -0
  30. sage/plot/contour_plot.py +1792 -0
  31. sage/plot/density_plot.py +318 -0
  32. sage/plot/disk.py +373 -0
  33. sage/plot/ellipse.py +375 -0
  34. sage/plot/graphics.py +3580 -0
  35. sage/plot/histogram.py +354 -0
  36. sage/plot/hyperbolic_arc.py +404 -0
  37. sage/plot/hyperbolic_polygon.py +416 -0
  38. sage/plot/hyperbolic_regular_polygon.py +296 -0
  39. sage/plot/line.py +626 -0
  40. sage/plot/matrix_plot.py +629 -0
  41. sage/plot/misc.py +509 -0
  42. sage/plot/multigraphics.py +1294 -0
  43. sage/plot/plot.py +4183 -0
  44. sage/plot/plot3d/all.py +23 -0
  45. sage/plot/plot3d/base.cpython-314-x86_64-linux-gnu.so +0 -0
  46. sage/plot/plot3d/base.pxd +12 -0
  47. sage/plot/plot3d/base.pyx +3378 -0
  48. sage/plot/plot3d/implicit_plot3d.py +659 -0
  49. sage/plot/plot3d/implicit_surface.cpython-314-x86_64-linux-gnu.so +0 -0
  50. sage/plot/plot3d/implicit_surface.pyx +1453 -0
  51. sage/plot/plot3d/index_face_set.cpython-314-x86_64-linux-gnu.so +0 -0
  52. sage/plot/plot3d/index_face_set.pxd +32 -0
  53. sage/plot/plot3d/index_face_set.pyx +1873 -0
  54. sage/plot/plot3d/introduction.py +131 -0
  55. sage/plot/plot3d/list_plot3d.py +649 -0
  56. sage/plot/plot3d/parametric_plot3d.py +1130 -0
  57. sage/plot/plot3d/parametric_surface.cpython-314-x86_64-linux-gnu.so +0 -0
  58. sage/plot/plot3d/parametric_surface.pxd +12 -0
  59. sage/plot/plot3d/parametric_surface.pyx +893 -0
  60. sage/plot/plot3d/platonic.py +601 -0
  61. sage/plot/plot3d/plot3d.py +1442 -0
  62. sage/plot/plot3d/plot_field3d.py +162 -0
  63. sage/plot/plot3d/point_c.pxi +148 -0
  64. sage/plot/plot3d/revolution_plot3d.py +309 -0
  65. sage/plot/plot3d/shapes.cpython-314-x86_64-linux-gnu.so +0 -0
  66. sage/plot/plot3d/shapes.pxd +22 -0
  67. sage/plot/plot3d/shapes.pyx +1382 -0
  68. sage/plot/plot3d/shapes2.py +1512 -0
  69. sage/plot/plot3d/tachyon.py +1779 -0
  70. sage/plot/plot3d/texture.py +453 -0
  71. sage/plot/plot3d/transform.cpython-314-x86_64-linux-gnu.so +0 -0
  72. sage/plot/plot3d/transform.pxd +21 -0
  73. sage/plot/plot3d/transform.pyx +268 -0
  74. sage/plot/plot3d/tri_plot.py +589 -0
  75. sage/plot/plot_field.py +362 -0
  76. sage/plot/point.py +624 -0
  77. sage/plot/polygon.py +562 -0
  78. sage/plot/primitive.py +249 -0
  79. sage/plot/scatter_plot.py +199 -0
  80. sage/plot/step.py +85 -0
  81. sage/plot/streamline_plot.py +328 -0
  82. sage/plot/text.py +432 -0
@@ -0,0 +1,659 @@
1
+ # sage_setup: distribution = sagemath-plot
2
+ # sage.doctest: needs sage.symbolic
3
+ """
4
+ Implicit plots
5
+ """
6
+ from .implicit_surface import ImplicitSurface
7
+
8
+
9
+ def implicit_plot3d(f, xrange, yrange, zrange, **kwds):
10
+ r"""
11
+ Plot an isosurface of a function.
12
+
13
+ INPUT:
14
+
15
+ - ``f`` -- function
16
+
17
+ - ``xrange`` -- a 2-tuple (x_min, x_max) or a 3-tuple (x, x_min, x_max)
18
+
19
+ - ``yrange`` -- a 2-tuple (y_min, y_max) or a 3-tuple (y, y_min, y_max)
20
+
21
+ - ``zrange`` -- a 2-tuple (z_min, z_max) or a 3-tuple (z, z_min, z_max)
22
+
23
+ - ``plot_points`` -- (default: "automatic", which is 40) the number of
24
+ function evaluations in each direction. (The number of cubes in the
25
+ marching cubes algorithm will be one less than this). Can be a triple of
26
+ integers, to specify a different resolution in each of x,y,z.
27
+
28
+ - ``contour`` -- (default: 0) plot the isosurface ``f(x,y,z) == contour``.
29
+ Can be a list, in which case multiple contours are plotted
30
+
31
+ - ``region`` -- (default: ``None``) if region is given, it must be a Python
32
+ callable. Only segments of the surface where ``region(x,y,z)`` returns a
33
+ number `>0` will be included in the plot. (Note that returning a Python
34
+ boolean is acceptable, since ``True == 1`` and ``False == 0``).
35
+
36
+ EXAMPLES::
37
+
38
+ sage: var('x,y,z')
39
+ (x, y, z)
40
+
41
+ A simple sphere::
42
+
43
+ sage: implicit_plot3d(x^2+y^2+z^2==4, (x,-3,3), (y,-3,3), (z,-3,3))
44
+ Graphics3d Object
45
+
46
+ .. PLOT::
47
+
48
+ var('x,y,z')
49
+ F = x**2 + y**2 + z**2
50
+ P = implicit_plot3d(F==4, (x,-3,3), (y,-3,3), (z,-3,3))
51
+ sphinx_plot(P)
52
+
53
+ A nested set of spheres with a hole cut out::
54
+
55
+ sage: F = x^2 + y^2 + z^2
56
+ sage: P = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), plot_points=60,
57
+ ....: contour=[1,3,5], color='aquamarine',
58
+ ....: region=lambda x,y,z: x<=0.2 or y>=0.2 or z<=0.2)
59
+ sage: P.show(viewer='tachyon') # long time
60
+
61
+ .. PLOT::
62
+
63
+ var('x,y,z')
64
+ F = x**2 + y**2 + z**2
65
+ P = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), plot_points=60, contour=[1,3,5],
66
+ region=lambda x,y,z: x<=0.2 or y>=0.2 or z<=0.2, color='aquamarine')
67
+ sphinx_plot(P)
68
+
69
+ A very pretty example, attributed to Douglas Summers-Stay (`archived page
70
+ <http://web.archive.org/web/20080529033738/http://iat.ubalt.edu/summers/math/platsol.htm>`_)::
71
+
72
+ sage: T = RDF(golden_ratio)
73
+ sage: F = 2 - (cos(x+T*y) + cos(x-T*y) + cos(y+T*z)
74
+ ....: + cos(y-T*z) + cos(z-T*x) + cos(z+T*x))
75
+ sage: r = 4.77
76
+ sage: implicit_plot3d(F, (x,-r,r), (y,-r,r), (z,-r,r),
77
+ ....: plot_points=40, color='darkkhaki').show(viewer='tachyon')
78
+
79
+ .. PLOT::
80
+
81
+ var('x,y,z')
82
+ T = RDF(golden_ratio)
83
+ F = 2 - (cos(x+T*y) + cos(x-T*y) + cos(y+T*z) + cos(y-T*z) + cos(z-T*x) + cos(z+T*x))
84
+ r = 4.77
85
+ V = implicit_plot3d(F, (x,-r,r), (y,-r,r), (z,-r,r), plot_points=40, color='darkkhaki')
86
+ sphinx_plot(V)
87
+
88
+ As I write this (but probably not as you read it), it's almost Valentine's
89
+ day, so let's try a heart (from http://mathworld.wolfram.com/HeartSurface.html)
90
+
91
+ ::
92
+
93
+ sage: F = (x^2+9/4*y^2+z^2-1)^3 - x^2*z^3 - 9/(80)*y^2*z^3
94
+ sage: r = 1.5
95
+ sage: V = implicit_plot3d(F, (x,-r,r), (y,-r,r), (z,-r,r),
96
+ ....: plot_points=80, color='red', smooth=False)
97
+ sage: V.show(viewer='tachyon') # long time
98
+
99
+ .. PLOT::
100
+
101
+ var('x,y,z')
102
+ F = (x**2+9.0/4.0*y**2+z**2-1)**3 - x**2*z**3 - 9.0/(80)*y**2*z**3
103
+ r = 1.5
104
+ V = implicit_plot3d(F, (x,-r,r), (y,-r,r), (z,-r,r), plot_points=80, color='red', smooth=False)
105
+ sphinx_plot(V)
106
+
107
+ The same examples also work with the default Jmol viewer; for example::
108
+
109
+ sage: T = RDF(golden_ratio)
110
+ sage: F = 2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z)
111
+ ....: + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))
112
+ sage: r = 4.77
113
+ sage: implicit_plot3d(F, (x,-r,r), (y,-r,r), (z,-r,r),
114
+ ....: plot_points=40, color='deepskyblue').show()
115
+
116
+ Here we use ``smooth=True`` with a Tachyon graph::
117
+
118
+ sage: implicit_plot3d(x^2 + y^2 + z^2, (x,-2,2), (y,-2,2), (z,-2,2),
119
+ ....: contour=4, color='deepskyblue', smooth=True)
120
+ Graphics3d Object
121
+
122
+ .. PLOT::
123
+
124
+ var('x,y,z')
125
+ F = x**2 + y**2 + z**2
126
+ P = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), contour=4, color='deepskyblue', smooth=True)
127
+ sphinx_plot(P)
128
+
129
+ We explicitly specify a gradient function (in conjunction with ``smooth=True``)
130
+ and invert the normals::
131
+
132
+ sage: gx = lambda x, y, z: -(2*x + y^2 + z^2)
133
+ sage: gy = lambda x, y, z: -(x^2 + 2*y + z^2)
134
+ sage: gz = lambda x, y, z: -(x^2 + y^2 + 2*z)
135
+ sage: implicit_plot3d(x^2+y^2+z^2, (x,-2,2), (y,-2,2), (z,-2,2),
136
+ ....: contour=4, plot_points=40, smooth=True,
137
+ ....: gradient=(gx, gy, gz)).show(viewer='tachyon')
138
+
139
+ .. PLOT::
140
+
141
+ var('x,y,z')
142
+ gx = lambda x, y, z: -(2*x + y**2 + z**2)
143
+ gy = lambda x, y, z: -(x**2 + 2*y + z**2)
144
+ gz = lambda x, y, z: -(x**2 + y**2 + 2*z)
145
+ P = implicit_plot3d(x**2+y**2+z**2, (x,-2,2), (y,-2,2), (z,-2,2), contour=4,
146
+ plot_points=40, smooth=True, gradient=(gx, gy, gz))
147
+ sphinx_plot(P)
148
+
149
+ A graph of two metaballs interacting with each other::
150
+
151
+ sage: def metaball(x0, y0, z0):
152
+ ....: return 1 / ((x-x0)^2+(y-y0)^2+(z-z0)^2)
153
+ sage: implicit_plot3d(metaball(-0.6,0,0) + metaball(0.6,0,0),
154
+ ....: (x,-2,2), (y,-2,2), (z,-2,2),
155
+ ....: plot_points=60, contour=2, color='seagreen')
156
+ Graphics3d Object
157
+
158
+ .. PLOT::
159
+
160
+ var('x,y,z')
161
+ def metaball(x0, y0, z0): return 1 / ((x-x0)**2+(y-y0)**2+(z-z0)**2)
162
+ P = implicit_plot3d(metaball(-0.6,0,0) + metaball(0.6,0,0), (x,-2,2), (y,-2,2), (z,-2,2), plot_points=60, contour=2, color='seagreen')
163
+ sphinx_plot(P)
164
+
165
+ One can also color the surface using a coloring function and a
166
+ colormap as follows. Note that the coloring function must take
167
+ values in the interval `[0,1]`. ::
168
+
169
+ sage: t = (sin(3*z)**2).function(x,y,z)
170
+ sage: cm = colormaps.gist_rainbow
171
+ sage: G = implicit_plot3d(x^2 + y^2 + z^2, (x,-2,2), (y,-2,2), (z,-2, 2),
172
+ ....: contour=4, color=(t,cm), plot_points=100)
173
+ sage: G.show(viewer='tachyon') # long time
174
+
175
+ .. PLOT::
176
+
177
+ var('x,y,z')
178
+ t = (sin(3*z)**2).function(x,y,z)
179
+ cm = colormaps.gist_rainbow
180
+ G = implicit_plot3d(x**2 + y**2 + z**2, (x,-2,2), (y,-2,2), (z,-2, 2),
181
+ contour=4, color=(t,cm), plot_points=60)
182
+ sphinx_plot(G)
183
+
184
+ Here is another colored example::
185
+
186
+ sage: x, y, z = var('x,y,z')
187
+ sage: t = (x).function(x,y,z)
188
+ sage: cm = colormaps.PiYG
189
+ sage: G = implicit_plot3d(x^4 + y^2 + z^2, (x,-2,2), (y,-2,2),(z,-2,2),
190
+ ....: contour=4, color=(t,cm), plot_points=40)
191
+ sage: G
192
+ Graphics3d Object
193
+
194
+ .. PLOT::
195
+
196
+ x, y, z = var('x,y,z')
197
+ t = (x).function(x,y,z)
198
+ cm = colormaps.PiYG
199
+ G = implicit_plot3d(x**4 + y**2 + z**2, (x,-2,2),
200
+ (y,-2,2),(z,-2,2), contour=4, color=(t,cm), plot_points=40)
201
+ sphinx_plot(G)
202
+
203
+ MANY MORE EXAMPLES:
204
+
205
+ A kind of saddle::
206
+
207
+ sage: implicit_plot3d(x^3 + y^2 - z^2, (x,-2,2), (y,-2,2), (z,-2,2),
208
+ ....: plot_points=60, contour=0, color='lightcoral')
209
+ Graphics3d Object
210
+
211
+ .. PLOT::
212
+
213
+ x, y, z = var('x,y,z')
214
+ G = implicit_plot3d(x**3 + y**2 - z**2, (x,-2,2), (y,-2,2), (z,-2,2), plot_points=60, contour=0, color='lightcoral')
215
+ sphinx_plot(G)
216
+
217
+ A smooth surface with six radial openings::
218
+
219
+ sage: implicit_plot3d(-(cos(x) + cos(y) + cos(z)),
220
+ ....: (x,-4,4), (y,-4,4), (z,-4,4), color='orchid')
221
+ Graphics3d Object
222
+
223
+ .. PLOT::
224
+
225
+ x, y, z = var('x,y,z')
226
+ G = implicit_plot3d(-(cos(x) + cos(y) + cos(z)), (x,-4,4), (y,-4,4), (z,-4,4), color='orchid')
227
+ sphinx_plot(G)
228
+
229
+ A cube composed of eight conjoined blobs::
230
+
231
+ sage: F = x^2 + y^2 + z^2 + cos(4*x) + cos(4*y) + cos(4*z) - 0.2
232
+ sage: implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='mediumspringgreen')
233
+ Graphics3d Object
234
+
235
+ .. PLOT::
236
+
237
+ x, y, z = var('x,y,z')
238
+ F = x**2 + y**2 + z**2 + cos(4*x) + cos(4*y) + cos(4*z) - 0.2
239
+ G = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='mediumspringgreen')
240
+ sphinx_plot(G)
241
+
242
+ A variation of the blob cube featuring heterogeneously sized blobs::
243
+
244
+ sage: F = x^2 + y^2 + z^2 + sin(4*x) + sin(4*y) + sin(4*z) - 1
245
+ sage: implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='lavenderblush')
246
+ Graphics3d Object
247
+
248
+ .. PLOT::
249
+
250
+ x, y, z = var('x,y,z')
251
+ F = x**2 + y**2 + z**2 + sin(4*x) + sin(4*y) + sin(4*z) - 1
252
+ G = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='lavenderblush')
253
+ sphinx_plot(G)
254
+
255
+ A Klein bottle::
256
+
257
+ sage: G = x^2 + y^2 + z^2
258
+ sage: F = (G+2*y-1)*((G-2*y-1)^2-8*z^2) + 16*x*z*(G-2*y-1)
259
+ sage: implicit_plot3d(F, (x,-3,3), (y,-3.1,3.1), (z,-4,4), color='moccasin')
260
+ Graphics3d Object
261
+
262
+ .. PLOT::
263
+
264
+ x, y, z = var('x,y,z')
265
+ G = x**2 + y**2 + z**2
266
+ F = (G+2*y-1)*((G-2*y-1)**2-8*z**2)+16*x*z*(G-2*y-1)
267
+ G = implicit_plot3d(F, (x,-3,3), (y,-3.1,3.1), (z,-4,4), color='moccasin')
268
+ sphinx_plot(G)
269
+
270
+ A lemniscate::
271
+
272
+ sage: F = 4*x^2*(x^2+y^2+z^2+z) + y^2*(y^2+z^2-1)
273
+ sage: implicit_plot3d(F, (x,-0.5,0.5), (y,-1,1), (z,-1,1), color='deeppink')
274
+ Graphics3d Object
275
+
276
+ .. PLOT::
277
+
278
+ x, y, z = var('x,y,z')
279
+ F = 4*x**2*(x**2+y**2+z**2+z) + y**2*(y**2+z**2-1)
280
+ G = implicit_plot3d(F, (x,-0.5,0.5), (y,-1,1), (z,-1,1), color='deeppink')
281
+ sphinx_plot(G)
282
+
283
+ Drope::
284
+
285
+ sage: implicit_plot3d(z - 4*x*exp(-x^2-y^2), (x,-2,2), (y,-2,2), (z,-1.7,1.7),
286
+ ....: color='darkcyan')
287
+ Graphics3d Object
288
+
289
+ .. PLOT::
290
+
291
+ x, y, z = var('x,y,z')
292
+ G = implicit_plot3d(z - 4*x*exp(-x**2-y**2), (x,-2,2), (y,-2,2), (z,-1.7,1.7), color='darkcyan')
293
+ sphinx_plot(G)
294
+
295
+ A cube with a circular aperture on each face::
296
+
297
+ sage: F = ((1/2.3)^2 * (x^2 + y^2 + z^2))^(-6) + ((1/2)^8 * (x^8 + y^8 + z^8))^6 - 1
298
+ sage: implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='palevioletred')
299
+ Graphics3d Object
300
+
301
+ .. PLOT::
302
+
303
+ x, y, z = var('x,y,z')
304
+ F = ((1/2.3)**2 * (x**2 + y**2 + z**2))**(-6) + ((1/2)**8 * (x**8 + y**8 + z**8))**6 - 1
305
+ G = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='palevioletred')
306
+ sphinx_plot(G)
307
+
308
+ A simple hyperbolic surface::
309
+
310
+ sage: implicit_plot3d(x^2 + y - z^2, (x,-1,1), (y,-1,1), (z,-1,1),
311
+ ....: color='darkslategray')
312
+ Graphics3d Object
313
+
314
+ .. PLOT::
315
+
316
+ x, y, z = var('x,y,z')
317
+ G = implicit_plot3d(x**2 + y - z**2, (x,-1,1), (y,-1,1), (z,-1,1), color='darkslategray')
318
+ sphinx_plot(G)
319
+
320
+ A hyperboloid::
321
+
322
+ sage: implicit_plot3d(x^2 + y^2 - z^2 -0.3, (x,-2,2), (y,-2,2), (z,-1.8,1.8),
323
+ ....: color='honeydew')
324
+ Graphics3d Object
325
+
326
+ .. PLOT::
327
+
328
+ x, y, z = var('x,y,z')
329
+ G = implicit_plot3d(x**2 + y**2 - z**2 -0.3, (x,-2,2), (y,-2,2), (z,-1.8,1.8), color='honeydew')
330
+ sphinx_plot(G)
331
+
332
+ Dupin cyclide (:wikipedia:`Dupin_cyclide`) ::
333
+
334
+ sage: x, y, z, a, b, c, d = var('x,y,z,a,b,c,d')
335
+ sage: a = 3.5
336
+ sage: b = 3
337
+ sage: c = sqrt(a^2 - b^2)
338
+ sage: d = 2
339
+ sage: F = (x^2 + y^2 + z^2 + b^2 - d^2)^2 - 4*(a*x-c*d)^2 - 4*b^2*y^2
340
+ sage: implicit_plot3d(F, (x,-6,6), (y,-6,6), (z,-6,6), color='seashell')
341
+ Graphics3d Object
342
+
343
+ .. PLOT::
344
+
345
+ x, y, z , a, b, c, d = var('x,y,z,a,b,c,d')
346
+ a = 3.5
347
+ b = 3
348
+ c = sqrt(a**2 - b**2)
349
+ d = 2
350
+ F = (x**2 + y**2 + z**2 + b**2 - d**2)**2 - 4*(a*x-c*d)**2 - 4*b**2*y**2
351
+ G = implicit_plot3d(F, (x,-6,6), (y,-6,6), (z,-6,6), color='seashell')
352
+ sphinx_plot(G)
353
+
354
+ Sinus::
355
+
356
+ sage: implicit_plot3d(sin(pi*((x)^2+(y)^2))/2 + z, (x,-1,1), (y,-1,1), (z,-1,1),
357
+ ....: color='rosybrown')
358
+ Graphics3d Object
359
+
360
+ .. PLOT::
361
+
362
+ x, y, z = var('x,y,z')
363
+ G = implicit_plot3d(sin(pi*((x)**2+(y)**2))/2 + z, (x,-1,1), (y,-1,1), (z,-1,1), color='rosybrown')
364
+ sphinx_plot(G)
365
+
366
+ A torus::
367
+
368
+ sage: implicit_plot3d((sqrt(x*x+y*y)-3)^2 + z*z - 1, (x,-4,4), (y,-4,4), (z,-1,1),
369
+ ....: color='indigo')
370
+ Graphics3d Object
371
+
372
+ .. PLOT::
373
+
374
+ x, y, z = var('x,y,z')
375
+ G = implicit_plot3d((sqrt(x*x+y*y)-3)**2 + z*z - 1, (x,-4,4), (y,-4,4), (z,-1,1), color='indigo')
376
+ sphinx_plot(G)
377
+
378
+ An octahedron::
379
+
380
+ sage: implicit_plot3d(abs(x) + abs(y) + abs(z) - 1, (x,-1,1), (y,-1,1), (z,-1,1),
381
+ ....: color='olive')
382
+ Graphics3d Object
383
+
384
+ .. PLOT::
385
+
386
+ x, y, z = var('x,y,z')
387
+ G = implicit_plot3d(abs(x) + abs(y) + abs(z) - 1, (x,-1,1), (y,-1,1), (z,-1,1), color='olive')
388
+ sphinx_plot(G)
389
+
390
+ A cube::
391
+
392
+ sage: implicit_plot3d(x^100 + y^100 + z^100 - 1, (x,-2,2), (y,-2,2), (z,-2,2),
393
+ ....: color='lightseagreen')
394
+ Graphics3d Object
395
+
396
+ .. PLOT::
397
+
398
+ x, y, z = var('x,y,z')
399
+ G = implicit_plot3d(x**100 + y**100 + z**100 - 1, (x,-2,2), (y,-2,2), (z,-2,2), color='lightseagreen')
400
+ sphinx_plot(G)
401
+
402
+ Toupie::
403
+
404
+ sage: implicit_plot3d((sqrt(x*x+y*y)-3)^3 + z*z - 1, (x,-4,4), (y,-4,4), (z,-6,6),
405
+ ....: color='mintcream')
406
+ Graphics3d Object
407
+
408
+ .. PLOT::
409
+
410
+ x, y, z = var('x,y,z')
411
+ G = implicit_plot3d((sqrt(x*x+y*y)-3)**3 + z*z - 1, (x,-4,4), (y,-4,4), (z,-6,6), color='mintcream')
412
+ sphinx_plot(G)
413
+
414
+ A cube with rounded edges::
415
+
416
+ sage: F = x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)
417
+ sage: implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='mediumvioletred')
418
+ Graphics3d Object
419
+
420
+ .. PLOT::
421
+
422
+ x, y, z = var('x,y,z')
423
+ F = x**4 + y**4 + z**4 - (x**2 + y**2 + z**2)
424
+ G = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='mediumvioletred')
425
+ sphinx_plot(G)
426
+
427
+ Chmutov::
428
+
429
+ sage: F = x^4 + y^4 + z^4 - (x^2 + y^2 + z^2 - 0.3)
430
+ sage: implicit_plot3d(F, (x,-1.5,1.5), (y,-1.5,1.5), (z,-1.5,1.5),
431
+ ....: color='lightskyblue')
432
+ Graphics3d Object
433
+
434
+ .. PLOT::
435
+
436
+ x, y, z = var('x,y,z')
437
+ F = x**4 + y**4 + z**4 - (x**2 + y**2 + z**2 - 0.3)
438
+ G = implicit_plot3d(F, (x,-1.5,1.5), (y,-1.5,1.5), (z,-1.5,1.5), color='lightskyblue')
439
+ sphinx_plot(G)
440
+
441
+ Further Chmutov::
442
+
443
+ sage: F = 2*(x^2*(3-4*x^2)^2+y^2*(3-4*y^2)^2+z^2*(3-4*z^2)^2) - 3
444
+ sage: implicit_plot3d(F, (x,-1.3,1.3), (y,-1.3,1.3), (z,-1.3,1.3),
445
+ ....: color='darksalmon')
446
+ Graphics3d Object
447
+
448
+ .. PLOT::
449
+
450
+ x, y, z = var('x,y,z')
451
+ F = 2*(x**2*(3-4*x**2)**2+y**2*(3-4*y**2)**2+z**2*(3-4*z**2)**2) - 3
452
+ G = implicit_plot3d(F, (x,-1.3,1.3), (y,-1.3,1.3), (z,-1.3,1.3), color='darksalmon')
453
+ sphinx_plot(G)
454
+
455
+ Clebsch surface::
456
+
457
+ sage: F_1 = 81 * (x^3+y^3+z^3)
458
+ sage: F_2 = 189 * (x^2*(y+z)+y^2*(x+z)+z^2*(x+y))
459
+ sage: F_3 = 54 * x * y * z
460
+ sage: F_4 = 126 * (x*y+x*z+y*z)
461
+ sage: F_5 = 9 * (x^2+y^2+z^2)
462
+ sage: F_6 = 9 * (x+y+z)
463
+ sage: F = F_1 - F_2 + F_3 + F_4 - F_5 + F_6 + 1
464
+ sage: implicit_plot3d(F, (x,-1,1), (y,-1,1), (z,-1,1), color='yellowgreen')
465
+ Graphics3d Object
466
+
467
+ .. PLOT::
468
+
469
+ x, y, z = var('x,y,z')
470
+ F_1 = 81 * (x**3+y**3+z**3)
471
+ F_2 = 189 * (x**2*(y+z)+y**2*(x+z)+z**2*(x+y))
472
+ F_3 = 54 * x * y * z
473
+ F_4 = 126 * (x*y+x*z+y*z)
474
+ F_5 = 9 * (x**2+y**2+z**2)
475
+ F_6 = 9 * (x+y+z)
476
+ F = F_1 - F_2 + F_3 + F_4 - F_5 + F_6 + 1
477
+ G = implicit_plot3d(F, (x,-1,1), (y,-1,1), (z,-1,1), color='yellowgreen')
478
+ sphinx_plot(G)
479
+
480
+ Looks like a water droplet::
481
+
482
+ sage: implicit_plot3d(x^2 + y^2 - (1-z)*z^2, (x,-1.5,1.5), (y,-1.5,1.5), (z,-1,1),
483
+ ....: color='bisque')
484
+ Graphics3d Object
485
+
486
+ .. PLOT::
487
+
488
+ x, y, z = var('x,y,z')
489
+ G = implicit_plot3d(x**2 +y**2 -(1-z)*z**2, (x,-1.5,1.5), (y,-1.5,1.5), (z,-1,1), color='bisque')
490
+ sphinx_plot(G)
491
+
492
+ Sphere in a cage::
493
+
494
+ sage: F = (x^8+z^30+y^8-(x^4 + z^50 + y^4 -0.3)) * (x^2+y^2+z^2-0.5)
495
+ sage: implicit_plot3d(F, (x,-1.2,1.2), (y,-1.3,1.3), (z,-1.5,1.5),
496
+ ....: color='firebrick')
497
+ Graphics3d Object
498
+
499
+ .. PLOT::
500
+
501
+ x, y, z = var('x,y,z')
502
+ F = (x**8+z**30+y**8-(x**4 + z**50 + y**4 -0.3)) * (x**2+y**2+z**2-0.5)
503
+ G = implicit_plot3d(F, (x,-1.2,1.2), (y,-1.3,1.3), (z,-1.5,1.5), color='firebrick')
504
+ sphinx_plot(G)
505
+
506
+ Ortho circle::
507
+
508
+ sage: F = (((x^2+y^2-1)^2+z^2) * ((y^2+z^2-1)^2+x^2) * ((z^2+x^2-1)^2+y^2)
509
+ ....: - 0.075^2 * (1+3*(x^2+y^2+z^2)))
510
+ sage: implicit_plot3d(F, (x,-1.5,1.5), (y,-1.5,1.5), (z,-1.5,1.5),
511
+ ....: color='lemonchiffon')
512
+ Graphics3d Object
513
+
514
+ .. PLOT::
515
+
516
+ x, y, z = var('x,y,z')
517
+ F = ((x**2+y**2-1)**2+z**2) * ((y**2+z**2-1)**2+x**2) * ((z**2+x**2-1)**2+y**2)-0.075**2 * (1+3*(x**2+y**2+z**2))
518
+ G = implicit_plot3d(F, (x,-1.5,1.5), (y,-1.5,1.5), (z,-1.5,1.5), color='lemonchiffon')
519
+ sphinx_plot(G)
520
+
521
+ Cube sphere::
522
+
523
+ sage: F = 12 - ((1/2.3)^2 *(x^2 + y^2 + z^2))^-6 - ((1/2)^8 * (x^8 + y^8 + z^8))^6
524
+ sage: implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='rosybrown')
525
+ Graphics3d Object
526
+
527
+ .. PLOT::
528
+
529
+ x, y, z = var('x,y,z')
530
+ F = 12 - ((1/2.3)**2 *(x**2 + y**2 + z**2))**-6 - ( (1/2)**8 * (x**8 + y**8 + z**8) )**6
531
+ G = implicit_plot3d(F, (x,-2,2), (y,-2,2), (z,-2,2), color='rosybrown')
532
+ sphinx_plot(G)
533
+
534
+ Two cylinders intersect to make a cross::
535
+
536
+ sage: implicit_plot3d((x^2+y^2-1) * (x^2+z^2-1) - 1, (x,-3,3), (y,-3,3), (z,-3,3),
537
+ ....: color='burlywood')
538
+ Graphics3d Object
539
+
540
+ .. PLOT::
541
+
542
+ x, y, z = var('x,y,z')
543
+ G = implicit_plot3d((x**2+y**2-1) * (x**2+z**2-1) - 1, (x,-3,3), (y,-3,3), (z,-3,3), color='burlywood')
544
+ sphinx_plot(G)
545
+
546
+ Three cylinders intersect in a similar fashion::
547
+
548
+ sage: implicit_plot3d((x^2+y^2-1) * (x^2+z^2-1) * (y^2+z^2-1) - 1,
549
+ ....: (x,-3,3), (y,-3,3), (z,-3,3), color='aqua')
550
+ Graphics3d Object
551
+
552
+ .. PLOT::
553
+
554
+ x, y, z = var('x,y,z')
555
+ G = implicit_plot3d((x**2+y**2-1) * (x**2+z**2-1) * (y**2+z**2-1)-1, (x,-3,3), (y,-3,3), (z,-3,3), color='aqua')
556
+ sphinx_plot(G)
557
+
558
+ A sphere-ish object with twelve holes, four on each XYZ plane::
559
+
560
+ sage: implicit_plot3d(3*(cos(x)+cos(y)+cos(z)) + 4*cos(x)*cos(y)*cos(z),
561
+ ....: (x,-3,3), (y,-3,3), (z,-3,3), color='orangered')
562
+ Graphics3d Object
563
+
564
+ .. PLOT::
565
+
566
+ x, y, z = var('x,y,z')
567
+ G = implicit_plot3d(3*(cos(x)+cos(y)+cos(z)) + 4*cos(x)*cos(y)*cos(z), (x,-3,3), (y,-3,3), (z,-3,3), color='orangered')
568
+ sphinx_plot(G)
569
+
570
+ A gyroid::
571
+
572
+ sage: implicit_plot3d(cos(x)*sin(y) + cos(y)*sin(z) + cos(z)*sin(x),
573
+ ....: (x,-4,4), (y,-4,4), (z,-4,4), color='sandybrown')
574
+ Graphics3d Object
575
+
576
+ .. PLOT::
577
+
578
+ x, y, z = var('x,y,z')
579
+ G = implicit_plot3d(cos(x)*sin(y) + cos(y)*sin(z) + cos(z)*sin(x), (x,-4,4), (y,-4,4), (z,-4,4), color='sandybrown')
580
+ sphinx_plot(G)
581
+
582
+ Tetrahedra::
583
+
584
+ sage: implicit_plot3d((x^2+y^2+z^2)^2 + 8*x*y*z - 10*(x^2+y^2+z^2) + 25,
585
+ ....: (x,-4,4), (y,-4,4), (z,-4,4), color='plum')
586
+ Graphics3d Object
587
+
588
+ .. PLOT::
589
+
590
+ x, y, z = var('x,y,z')
591
+ G = implicit_plot3d((x**2+y**2+z**2)**2 + 8*x*y*z - 10*(x**2+y**2+z**2) + 25, (x,-4,4), (y,-4,4), (z,-4,4), color='plum')
592
+ sphinx_plot(G)
593
+
594
+ TESTS:
595
+
596
+ Test a separate resolution in the X direction; this should look like a
597
+ regular sphere::
598
+
599
+ sage: implicit_plot3d(x^2 + y^2 + z^2, (x,-2,2), (y,-2,2), (z,-2,2), plot_points=(10,40,40), contour=4)
600
+ Graphics3d Object
601
+
602
+ Test using different plot ranges in the different directions; each
603
+ of these should generate half of a sphere. Note that we need to use
604
+ the ``aspect_ratio`` keyword to make it look right with the unequal
605
+ plot ranges::
606
+
607
+ sage: implicit_plot3d(x^2 + y^2 + z^2, (x,0,2), (y,-2,2), (z,-2,2), contour=4, aspect_ratio=1)
608
+ Graphics3d Object
609
+
610
+ sage: implicit_plot3d(x^2 + y^2 + z^2, (x,-2,2), (y,0,2), (z,-2,2), contour=4, aspect_ratio=1)
611
+ Graphics3d Object
612
+
613
+ sage: implicit_plot3d(x^2 + y^2 + z^2, (x,-2,2), (y,-2,2), (z,0,2), contour=4, aspect_ratio=1)
614
+ Graphics3d Object
615
+
616
+ Extra keyword arguments will be passed to show()::
617
+
618
+ sage: implicit_plot3d(x^2 + y^2 + z^2, (x,-2,2), (y,-2,2), (z,-2,2), contour=4, viewer='tachyon')
619
+ Graphics3d Object
620
+
621
+ An implicit plot that does not include any surface in the view volume
622
+ produces an empty plot::
623
+
624
+ sage: implicit_plot3d(x^2 + y^2 + z^2 - 5000, (x,-2,2), (y,-2,2), (z,-2,2), plot_points=6)
625
+ Graphics3d Object
626
+
627
+ Make sure that implicit_plot3d does not error if the function cannot
628
+ be symbolically differentiated::
629
+
630
+ sage: implicit_plot3d(max_symbolic(x, y^2) - z, (x,-2,2), (y,-2,2), (z,-2,2), plot_points=6)
631
+ Graphics3d Object
632
+
633
+ TESTS:
634
+
635
+ Check for :issue:`10599`::
636
+
637
+ sage: var('x,y,z')
638
+ (x, y, z)
639
+ sage: M = matrix(3,[1,-1,-1,-1,3,1,-1,1,3])
640
+ sage: v = 1/M.eigenvalues()[1]
641
+ sage: implicit_plot3d(x^2+y^2+z^2==v, [x,-3,3], [y,-3,3],[z,-3,3])
642
+ Graphics3d Object
643
+ """
644
+ # These options, related to rendering with smooth shading, are irrelevant
645
+ # since IndexFaceSet does not support surface normals:
646
+ # smooth: (default: ``False``) Whether to use vertex normals to produce a
647
+ # smooth-looking surface. False is slightly faster.
648
+ # gradient: (default: None) If smooth is True (the default), then
649
+ # Tachyon rendering needs vertex normals. In that case, if gradient is None
650
+ # (the default), then we try to differentiate the function to get the
651
+ # gradient. If that fails, then we use central differencing on the scalar
652
+ # field. But it's also possible to specify the gradient; this must be either
653
+ # a single python callable that takes (x,y,z) and returns a tuple (dx,dy,dz)
654
+ # or a tuple of three callables that each take (x,y,z) and return dx, dy, dz
655
+ # respectively.
656
+
657
+ G = ImplicitSurface(f, xrange, yrange, zrange, **kwds)
658
+ G._set_extra_kwds(kwds)
659
+ return G