passagemath-plot 10.6.31rc3__cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.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.
- passagemath_plot-10.6.31rc3.dist-info/METADATA +172 -0
- passagemath_plot-10.6.31rc3.dist-info/RECORD +81 -0
- passagemath_plot-10.6.31rc3.dist-info/WHEEL +6 -0
- passagemath_plot-10.6.31rc3.dist-info/top_level.txt +2 -0
- passagemath_plot.libs/libgfortran-e1b7dfc8.so.5.0.0 +0 -0
- passagemath_plot.libs/libgsl-e3525837.so.28.0.0 +0 -0
- passagemath_plot.libs/libopenblasp-r0-4c5b64b1.3.29.so +0 -0
- sage/all__sagemath_plot.py +15 -0
- sage/ext_data/threejs/animation.css +195 -0
- sage/ext_data/threejs/animation.html +85 -0
- sage/ext_data/threejs/animation.js +273 -0
- sage/ext_data/threejs/fat_lines.js +48 -0
- sage/ext_data/threejs/threejs-version.txt +1 -0
- sage/ext_data/threejs/threejs_template.html +597 -0
- sage/interfaces/all__sagemath_plot.py +1 -0
- sage/interfaces/gnuplot.py +196 -0
- sage/interfaces/jmoldata.py +208 -0
- sage/interfaces/povray.py +56 -0
- sage/plot/all.py +42 -0
- sage/plot/animate.py +1796 -0
- sage/plot/arc.py +504 -0
- sage/plot/arrow.py +671 -0
- sage/plot/bar_chart.py +205 -0
- sage/plot/bezier_path.py +400 -0
- sage/plot/circle.py +435 -0
- sage/plot/colors.py +1606 -0
- sage/plot/complex_plot.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/complex_plot.pyx +1446 -0
- sage/plot/contour_plot.py +1792 -0
- sage/plot/density_plot.py +318 -0
- sage/plot/disk.py +373 -0
- sage/plot/ellipse.py +375 -0
- sage/plot/graphics.py +3580 -0
- sage/plot/histogram.py +354 -0
- sage/plot/hyperbolic_arc.py +404 -0
- sage/plot/hyperbolic_polygon.py +416 -0
- sage/plot/hyperbolic_regular_polygon.py +296 -0
- sage/plot/line.py +626 -0
- sage/plot/matrix_plot.py +629 -0
- sage/plot/misc.py +509 -0
- sage/plot/multigraphics.py +1294 -0
- sage/plot/plot.py +4183 -0
- sage/plot/plot3d/all.py +23 -0
- sage/plot/plot3d/base.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/base.pxd +12 -0
- sage/plot/plot3d/base.pyx +3378 -0
- sage/plot/plot3d/implicit_plot3d.py +659 -0
- sage/plot/plot3d/implicit_surface.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/implicit_surface.pyx +1453 -0
- sage/plot/plot3d/index_face_set.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/index_face_set.pxd +32 -0
- sage/plot/plot3d/index_face_set.pyx +1873 -0
- sage/plot/plot3d/introduction.py +131 -0
- sage/plot/plot3d/list_plot3d.py +649 -0
- sage/plot/plot3d/parametric_plot3d.py +1130 -0
- sage/plot/plot3d/parametric_surface.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/parametric_surface.pxd +12 -0
- sage/plot/plot3d/parametric_surface.pyx +893 -0
- sage/plot/plot3d/platonic.py +601 -0
- sage/plot/plot3d/plot3d.py +1442 -0
- sage/plot/plot3d/plot_field3d.py +162 -0
- sage/plot/plot3d/point_c.pxi +148 -0
- sage/plot/plot3d/revolution_plot3d.py +309 -0
- sage/plot/plot3d/shapes.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/shapes.pxd +22 -0
- sage/plot/plot3d/shapes.pyx +1382 -0
- sage/plot/plot3d/shapes2.py +1512 -0
- sage/plot/plot3d/tachyon.py +1779 -0
- sage/plot/plot3d/texture.py +453 -0
- sage/plot/plot3d/transform.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/plot/plot3d/transform.pxd +21 -0
- sage/plot/plot3d/transform.pyx +268 -0
- sage/plot/plot3d/tri_plot.py +589 -0
- sage/plot/plot_field.py +362 -0
- sage/plot/point.py +624 -0
- sage/plot/polygon.py +562 -0
- sage/plot/primitive.py +249 -0
- sage/plot/scatter_plot.py +199 -0
- sage/plot/step.py +85 -0
- sage/plot/streamline_plot.py +328 -0
- sage/plot/text.py +432 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-plot
|
|
2
|
+
r"""
|
|
3
|
+
Texture support
|
|
4
|
+
|
|
5
|
+
This module provides texture/material support for 3D Graphics
|
|
6
|
+
objects and plotting. This is a very rough common interface for
|
|
7
|
+
Tachyon, x3d, and obj (mtl). See :class:`Texture
|
|
8
|
+
<sage.plot.plot3d.texture.Texture>` for full details about options and use.
|
|
9
|
+
|
|
10
|
+
Initially, we have no textures set::
|
|
11
|
+
|
|
12
|
+
sage: sage.plot.plot3d.base.Graphics3d().texture_set()
|
|
13
|
+
set()
|
|
14
|
+
|
|
15
|
+
However, one can access these textures in the following manner::
|
|
16
|
+
|
|
17
|
+
sage: G = tetrahedron(color='red') + tetrahedron(color='yellow') + tetrahedron(color='red', opacity=0.5)
|
|
18
|
+
sage: [t for t in G.texture_set() if t.color == colors.red] # we should have two red textures
|
|
19
|
+
[Texture(texture..., red, ff0000), Texture(texture..., red, ff0000)]
|
|
20
|
+
sage: [t for t in G.texture_set() if t.color == colors.yellow] # ...and one yellow
|
|
21
|
+
[Texture(texture..., yellow, ffff00)]
|
|
22
|
+
|
|
23
|
+
And the Texture objects keep track of all their data::
|
|
24
|
+
|
|
25
|
+
sage: T = tetrahedron(color='red', opacity=0.5)
|
|
26
|
+
sage: t = T.get_texture()
|
|
27
|
+
sage: t.opacity
|
|
28
|
+
0.5
|
|
29
|
+
sage: T # should be translucent
|
|
30
|
+
Graphics3d Object
|
|
31
|
+
|
|
32
|
+
AUTHOR:
|
|
33
|
+
|
|
34
|
+
- Robert Bradshaw (2007-07-07) Initial version.
|
|
35
|
+
"""
|
|
36
|
+
from textwrap import dedent
|
|
37
|
+
|
|
38
|
+
from sage.misc.classcall_metaclass import ClasscallMetaclass, typecall
|
|
39
|
+
from sage.misc.fast_methods import WithEqualityById
|
|
40
|
+
from sage.structure.sage_object import SageObject
|
|
41
|
+
|
|
42
|
+
from sage.plot.colors import colors, Color
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
uniq_c = 0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _new_global_texture_id():
|
|
49
|
+
"""
|
|
50
|
+
Generate a new unique id for a texture.
|
|
51
|
+
|
|
52
|
+
EXAMPLES::
|
|
53
|
+
|
|
54
|
+
sage: sage.plot.plot3d.texture._new_global_texture_id()
|
|
55
|
+
'texture...'
|
|
56
|
+
sage: sage.plot.plot3d.texture._new_global_texture_id()
|
|
57
|
+
'texture...'
|
|
58
|
+
"""
|
|
59
|
+
global uniq_c
|
|
60
|
+
uniq_c += 1
|
|
61
|
+
return "texture%s" % uniq_c
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def is_Texture(x):
|
|
65
|
+
r"""
|
|
66
|
+
Deprecated. Use ``isinstance(x, Texture)`` instead.
|
|
67
|
+
|
|
68
|
+
EXAMPLES::
|
|
69
|
+
|
|
70
|
+
sage: from sage.plot.plot3d.texture import is_Texture, Texture
|
|
71
|
+
sage: t = Texture(0.5)
|
|
72
|
+
sage: is_Texture(t)
|
|
73
|
+
doctest:...: DeprecationWarning: Please use isinstance(x, Texture)
|
|
74
|
+
See https://github.com/sagemath/sage/issues/27593 for details.
|
|
75
|
+
True
|
|
76
|
+
"""
|
|
77
|
+
from sage.misc.superseded import deprecation
|
|
78
|
+
deprecation(27593, "Please use isinstance(x, Texture)")
|
|
79
|
+
return isinstance(x, Texture)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def parse_color(info, base=None):
|
|
83
|
+
r"""
|
|
84
|
+
Parse the color.
|
|
85
|
+
|
|
86
|
+
It transforms a valid color string into a color object and
|
|
87
|
+
a color object into an RBG tuple of length 3. Otherwise,
|
|
88
|
+
it multiplies the info by the base color.
|
|
89
|
+
|
|
90
|
+
INPUT:
|
|
91
|
+
|
|
92
|
+
- ``info`` -- color, valid color str or number
|
|
93
|
+
- ``base`` -- tuple of length 3 (default: ``None``)
|
|
94
|
+
|
|
95
|
+
OUTPUT: a tuple or color
|
|
96
|
+
|
|
97
|
+
EXAMPLES:
|
|
98
|
+
|
|
99
|
+
From a color::
|
|
100
|
+
|
|
101
|
+
sage: from sage.plot.plot3d.texture import parse_color
|
|
102
|
+
sage: c = Color('red')
|
|
103
|
+
sage: parse_color(c)
|
|
104
|
+
(1.0, 0.0, 0.0)
|
|
105
|
+
|
|
106
|
+
From a valid color str::
|
|
107
|
+
|
|
108
|
+
sage: parse_color('red')
|
|
109
|
+
RGB color (1.0, 0.0, 0.0)
|
|
110
|
+
sage: parse_color('#ff0000')
|
|
111
|
+
RGB color (1.0, 0.0, 0.0)
|
|
112
|
+
|
|
113
|
+
From a non valid color str::
|
|
114
|
+
|
|
115
|
+
sage: parse_color('redd')
|
|
116
|
+
Traceback (most recent call last):
|
|
117
|
+
...
|
|
118
|
+
ValueError: unknown color 'redd'
|
|
119
|
+
|
|
120
|
+
From an info and a base::
|
|
121
|
+
|
|
122
|
+
sage: opacity = 10
|
|
123
|
+
sage: parse_color(opacity, base=(.2,.3,.4))
|
|
124
|
+
(2.0, 3.0, 4.0)
|
|
125
|
+
"""
|
|
126
|
+
if isinstance(info, Color):
|
|
127
|
+
return info.rgb()
|
|
128
|
+
elif isinstance(info, str):
|
|
129
|
+
try:
|
|
130
|
+
return Color(info)
|
|
131
|
+
except KeyError:
|
|
132
|
+
raise ValueError("unknown color '%s'" % info)
|
|
133
|
+
else:
|
|
134
|
+
r, g, b = base
|
|
135
|
+
# We don't want to lose the data when we split it into its respective components.
|
|
136
|
+
if not r:
|
|
137
|
+
r = 1e-5
|
|
138
|
+
if not g:
|
|
139
|
+
g = 1e-5
|
|
140
|
+
if not b:
|
|
141
|
+
b = 1e-5
|
|
142
|
+
return (float(info * r), float(info * g), float(info * b))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class Texture(WithEqualityById, SageObject, metaclass=ClasscallMetaclass):
|
|
146
|
+
r"""
|
|
147
|
+
Class representing a texture.
|
|
148
|
+
|
|
149
|
+
See documentation of :meth:`Texture.__classcall__
|
|
150
|
+
<sage.plot.plot3d.texture.Texture.__classcall__>` for more details and
|
|
151
|
+
examples.
|
|
152
|
+
|
|
153
|
+
EXAMPLES:
|
|
154
|
+
|
|
155
|
+
We create a translucent texture::
|
|
156
|
+
|
|
157
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
158
|
+
sage: t = Texture(opacity=0.6)
|
|
159
|
+
sage: t
|
|
160
|
+
Texture(texture..., 6666ff)
|
|
161
|
+
sage: t.opacity
|
|
162
|
+
0.6
|
|
163
|
+
sage: t.jmol_str('obj')
|
|
164
|
+
'color obj translucent 0.4 [102,102,255]'
|
|
165
|
+
sage: t.mtl_str()
|
|
166
|
+
'newmtl texture...\nKa 0.2 0.2 0.5\nKd 0.4 0.4 1.0\nKs 0.0 0.0 0.0\nillum 1\nNs 1.0\nd 0.6'
|
|
167
|
+
sage: t.x3d_str()
|
|
168
|
+
"<Appearance><Material diffuseColor='0.4 0.4 1.0' shininess='1.0' specularColor='0.0 0.0 0.0'/></Appearance>"
|
|
169
|
+
|
|
170
|
+
TESTS::
|
|
171
|
+
|
|
172
|
+
sage: Texture(opacity=1/3).opacity
|
|
173
|
+
0.3333333333333333
|
|
174
|
+
|
|
175
|
+
sage: hash(Texture()) # random
|
|
176
|
+
42
|
|
177
|
+
"""
|
|
178
|
+
@staticmethod
|
|
179
|
+
def __classcall__(cls, id=None, **kwds):
|
|
180
|
+
r"""
|
|
181
|
+
Construct a new texture by id.
|
|
182
|
+
|
|
183
|
+
INPUT:
|
|
184
|
+
|
|
185
|
+
- ``id`` -- a texture (default: ``None``), a dictionary, a color, a
|
|
186
|
+
string, a tuple, ``None`` or any other type acting as an ID. If ``id`` is
|
|
187
|
+
``None`` and keyword ``texture`` is empty, then it returns a unique texture object.
|
|
188
|
+
- ``texture`` -- a texture
|
|
189
|
+
- ``color`` -- tuple or string (default: (.4, .4, 1))
|
|
190
|
+
- ``opacity`` -- number between 0 and 1 (default: 1)
|
|
191
|
+
- ``ambient`` -- number (default: 0.5)
|
|
192
|
+
- ``diffuse`` -- number (default: 1)
|
|
193
|
+
- ``specular`` -- number (default: 0)
|
|
194
|
+
- ``shininess`` -- number (default: 1)
|
|
195
|
+
- ``name`` -- string (default: ``None``)
|
|
196
|
+
- ``**kwds`` -- other valid keywords
|
|
197
|
+
|
|
198
|
+
OUTPUT: a texture object
|
|
199
|
+
|
|
200
|
+
EXAMPLES:
|
|
201
|
+
|
|
202
|
+
Texture from integer ``id``::
|
|
203
|
+
|
|
204
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
205
|
+
sage: Texture(17)
|
|
206
|
+
Texture(17, 6666ff)
|
|
207
|
+
|
|
208
|
+
Texture from rational ``id``::
|
|
209
|
+
|
|
210
|
+
sage: Texture(3/4)
|
|
211
|
+
Texture(3/4, 6666ff)
|
|
212
|
+
|
|
213
|
+
Texture from a dict::
|
|
214
|
+
|
|
215
|
+
sage: Texture({'color':'orange','opacity':0.5})
|
|
216
|
+
Texture(texture..., orange, ffa500)
|
|
217
|
+
|
|
218
|
+
Texture from a color::
|
|
219
|
+
|
|
220
|
+
sage: c = Color('red')
|
|
221
|
+
sage: Texture(c)
|
|
222
|
+
Texture(texture..., ff0000)
|
|
223
|
+
|
|
224
|
+
Texture from a valid string color::
|
|
225
|
+
|
|
226
|
+
sage: Texture('red')
|
|
227
|
+
Texture(texture..., red, ff0000)
|
|
228
|
+
|
|
229
|
+
Texture from a non valid string color::
|
|
230
|
+
|
|
231
|
+
sage: Texture('redd')
|
|
232
|
+
Texture(redd, 6666ff)
|
|
233
|
+
|
|
234
|
+
Texture from a tuple::
|
|
235
|
+
|
|
236
|
+
sage: Texture((.2,.3,.4))
|
|
237
|
+
Texture(texture..., 334c66)
|
|
238
|
+
|
|
239
|
+
Now accepting negative arguments, reduced modulo 1::
|
|
240
|
+
|
|
241
|
+
sage: Texture((-3/8, 1/2, 3/8))
|
|
242
|
+
Texture(texture..., 9f7f5f)
|
|
243
|
+
|
|
244
|
+
Textures using other keywords::
|
|
245
|
+
|
|
246
|
+
sage: Texture(specular=0.4)
|
|
247
|
+
Texture(texture..., 6666ff)
|
|
248
|
+
sage: Texture(diffuse=0.4)
|
|
249
|
+
Texture(texture..., 6666ff)
|
|
250
|
+
sage: Texture(shininess=0.3)
|
|
251
|
+
Texture(texture..., 6666ff)
|
|
252
|
+
sage: Texture(ambient=0.7)
|
|
253
|
+
Texture(texture..., 6666ff)
|
|
254
|
+
"""
|
|
255
|
+
if isinstance(id, Texture):
|
|
256
|
+
return id
|
|
257
|
+
if 'texture' in kwds:
|
|
258
|
+
t = kwds['texture']
|
|
259
|
+
if isinstance(t, Texture):
|
|
260
|
+
return t
|
|
261
|
+
else:
|
|
262
|
+
raise TypeError("texture keyword must be a texture object")
|
|
263
|
+
if isinstance(id, dict):
|
|
264
|
+
kwds = id
|
|
265
|
+
if 'rgbcolor' in kwds:
|
|
266
|
+
kwds['color'] = kwds['rgbcolor']
|
|
267
|
+
id = None
|
|
268
|
+
elif isinstance(id, Color):
|
|
269
|
+
kwds['color'] = id.rgb()
|
|
270
|
+
id = None
|
|
271
|
+
elif isinstance(id, str) and id in colors:
|
|
272
|
+
kwds['color'] = id
|
|
273
|
+
id = None
|
|
274
|
+
elif isinstance(id, tuple):
|
|
275
|
+
kwds['color'] = id
|
|
276
|
+
id = None
|
|
277
|
+
if id is None:
|
|
278
|
+
id = _new_global_texture_id()
|
|
279
|
+
return typecall(cls, id, **kwds)
|
|
280
|
+
|
|
281
|
+
def __init__(self, id, color=(.4, .4, 1), opacity=1, ambient=0.5,
|
|
282
|
+
diffuse=1, specular=0, shininess=1, name=None, **kwds):
|
|
283
|
+
r"""
|
|
284
|
+
Construction of a texture.
|
|
285
|
+
|
|
286
|
+
See documentation of :meth:`Texture.__classcall__
|
|
287
|
+
<sage.plot.plot3d.texture.Texture.__classcall__>` for more details and
|
|
288
|
+
examples.
|
|
289
|
+
|
|
290
|
+
EXAMPLES::
|
|
291
|
+
|
|
292
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
293
|
+
sage: Texture(3, opacity=0.6)
|
|
294
|
+
Texture(3, 6666ff)
|
|
295
|
+
"""
|
|
296
|
+
self.id = id
|
|
297
|
+
if name is None and isinstance(color, str):
|
|
298
|
+
name = color
|
|
299
|
+
self.name = name
|
|
300
|
+
|
|
301
|
+
if not isinstance(color, tuple):
|
|
302
|
+
color = parse_color(color)
|
|
303
|
+
else:
|
|
304
|
+
if len(color) == 4:
|
|
305
|
+
opacity = color[3]
|
|
306
|
+
color = tuple(float(1) if c == 1 else float(c) % 1
|
|
307
|
+
for c in color[0: 3])
|
|
308
|
+
|
|
309
|
+
self.color = color
|
|
310
|
+
self.opacity = float(opacity)
|
|
311
|
+
self.shininess = float(shininess)
|
|
312
|
+
|
|
313
|
+
if not isinstance(ambient, tuple):
|
|
314
|
+
ambient = parse_color(ambient, color)
|
|
315
|
+
self.ambient = ambient
|
|
316
|
+
|
|
317
|
+
if not isinstance(diffuse, tuple):
|
|
318
|
+
diffuse = parse_color(diffuse, color)
|
|
319
|
+
self.diffuse = diffuse
|
|
320
|
+
|
|
321
|
+
if not isinstance(specular, tuple):
|
|
322
|
+
specular = parse_color(specular, color)
|
|
323
|
+
self.specular = specular
|
|
324
|
+
|
|
325
|
+
def _repr_(self):
|
|
326
|
+
"""
|
|
327
|
+
Return a string representation of the Texture object.
|
|
328
|
+
|
|
329
|
+
EXAMPLES::
|
|
330
|
+
|
|
331
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
332
|
+
sage: Texture('yellow') #indirect doctest
|
|
333
|
+
Texture(texture..., yellow, ffff00)
|
|
334
|
+
sage: Texture((1,1,0), opacity=.5)
|
|
335
|
+
Texture(texture..., ffff00)
|
|
336
|
+
"""
|
|
337
|
+
if self.name is not None:
|
|
338
|
+
return f"Texture({self.id}, {self.name}, {self.hex_rgb()})"
|
|
339
|
+
else:
|
|
340
|
+
return f"Texture({self.id}, {self.hex_rgb()})"
|
|
341
|
+
|
|
342
|
+
def hex_rgb(self):
|
|
343
|
+
"""
|
|
344
|
+
EXAMPLES::
|
|
345
|
+
|
|
346
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
347
|
+
sage: Texture('red').hex_rgb()
|
|
348
|
+
'ff0000'
|
|
349
|
+
sage: Texture((1, .5, 0)).hex_rgb()
|
|
350
|
+
'ff7f00'
|
|
351
|
+
"""
|
|
352
|
+
return "{:02x}{:02x}{:02x}".format(*tuple(int(255 * s) for s in self.color))
|
|
353
|
+
|
|
354
|
+
def tachyon_str(self):
|
|
355
|
+
r"""
|
|
356
|
+
Convert Texture object to string suitable for Tachyon ray tracer.
|
|
357
|
+
|
|
358
|
+
EXAMPLES::
|
|
359
|
+
|
|
360
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
361
|
+
sage: t = Texture(opacity=0.6)
|
|
362
|
+
sage: t.tachyon_str()
|
|
363
|
+
'Texdef texture...\n Ambient 0.3333333333333333 Diffuse 0.6666666666666666 Specular 0.0 Opacity 0.6\n Color 0.4 0.4 1.0\n TexFunc 0'
|
|
364
|
+
"""
|
|
365
|
+
|
|
366
|
+
total_ambient = sum(self.ambient)
|
|
367
|
+
total_diffuse = sum(self.diffuse)
|
|
368
|
+
total_specular = sum(self.specular)
|
|
369
|
+
|
|
370
|
+
total_color = total_ambient + total_diffuse + total_specular
|
|
371
|
+
|
|
372
|
+
if total_color == 0:
|
|
373
|
+
total_color = 1
|
|
374
|
+
|
|
375
|
+
ambient = total_ambient / total_color
|
|
376
|
+
diffuse = total_diffuse / total_color
|
|
377
|
+
specular = total_specular / total_color
|
|
378
|
+
|
|
379
|
+
return dedent("""\
|
|
380
|
+
Texdef {id}
|
|
381
|
+
Ambient {ambient!r} Diffuse {diffuse!r} Specular {specular!r} Opacity {opacity!r}
|
|
382
|
+
Color {color[0]!r} {color[1]!r} {color[2]!r}
|
|
383
|
+
TexFunc 0""").format(id=self.id, ambient=ambient,
|
|
384
|
+
diffuse=diffuse, specular=specular,
|
|
385
|
+
opacity=self.opacity, color=self.color)
|
|
386
|
+
|
|
387
|
+
def x3d_str(self):
|
|
388
|
+
r"""
|
|
389
|
+
Convert Texture object to string suitable for x3d.
|
|
390
|
+
|
|
391
|
+
EXAMPLES::
|
|
392
|
+
|
|
393
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
394
|
+
sage: t = Texture(opacity=0.6)
|
|
395
|
+
sage: t.x3d_str()
|
|
396
|
+
"<Appearance><Material diffuseColor='0.4 0.4 1.0' shininess='1.0' specularColor='0.0 0.0 0.0'/></Appearance>"
|
|
397
|
+
"""
|
|
398
|
+
return (
|
|
399
|
+
"<Appearance>"
|
|
400
|
+
"<Material diffuseColor='{color[0]!r} {color[1]!r} {color[2]!r}' "
|
|
401
|
+
"shininess='{shininess!r}' "
|
|
402
|
+
"specularColor='{specular!r} {specular!r} {specular!r}'/>"
|
|
403
|
+
"</Appearance>").format(color=self.color, shininess=self.shininess,
|
|
404
|
+
specular=self.specular[0])
|
|
405
|
+
|
|
406
|
+
def mtl_str(self):
|
|
407
|
+
r"""
|
|
408
|
+
Convert Texture object to string suitable for mtl output.
|
|
409
|
+
|
|
410
|
+
EXAMPLES::
|
|
411
|
+
|
|
412
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
413
|
+
sage: t = Texture(opacity=0.6)
|
|
414
|
+
sage: t.mtl_str()
|
|
415
|
+
'newmtl texture...\nKa 0.2 0.2 0.5\nKd 0.4 0.4 1.0\nKs 0.0 0.0 0.0\nillum 1\nNs 1.0\nd 0.6'
|
|
416
|
+
"""
|
|
417
|
+
return dedent("""\
|
|
418
|
+
newmtl {id}
|
|
419
|
+
Ka {ambient[0]!r} {ambient[1]!r} {ambient[2]!r}
|
|
420
|
+
Kd {diffuse[0]!r} {diffuse[1]!r} {diffuse[2]!r}
|
|
421
|
+
Ks {specular[0]!r} {specular[1]!r} {specular[2]!r}
|
|
422
|
+
illum {illumination}
|
|
423
|
+
Ns {shininess!r}
|
|
424
|
+
d {opacity!r}"""
|
|
425
|
+
).format(id=self.id, ambient=self.ambient, diffuse=self.diffuse,
|
|
426
|
+
specular=self.specular,
|
|
427
|
+
illumination=(2 if sum(self.specular) > 0 else 1),
|
|
428
|
+
shininess=self.shininess, opacity=self.opacity)
|
|
429
|
+
|
|
430
|
+
def jmol_str(self, obj):
|
|
431
|
+
r"""
|
|
432
|
+
Convert Texture object to string suitable for Jmol applet.
|
|
433
|
+
|
|
434
|
+
INPUT:
|
|
435
|
+
|
|
436
|
+
- ``obj`` -- str
|
|
437
|
+
|
|
438
|
+
EXAMPLES::
|
|
439
|
+
|
|
440
|
+
sage: from sage.plot.plot3d.texture import Texture
|
|
441
|
+
sage: t = Texture(opacity=0.6)
|
|
442
|
+
sage: t.jmol_str('obj')
|
|
443
|
+
'color obj translucent 0.4 [102,102,255]'
|
|
444
|
+
|
|
445
|
+
::
|
|
446
|
+
|
|
447
|
+
sage: sum([dodecahedron(center=[2.5*x, 0, 0], color=(1, 0, 0, x/10)) for x in range(11)]).show(aspect_ratio=[1,1,1], frame=False, zoom=2)
|
|
448
|
+
"""
|
|
449
|
+
translucent = "translucent %s" % float(1 - self.opacity) if self.opacity < 1 else ""
|
|
450
|
+
return "color {} {} [{},{},{}]".format(obj, translucent,
|
|
451
|
+
int(255 * self.color[0]),
|
|
452
|
+
int(255 * self.color[1]),
|
|
453
|
+
int(255 * self.color[2]))
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-plot
|
|
2
|
+
cdef struct point_c:
|
|
3
|
+
double x, y, z
|
|
4
|
+
|
|
5
|
+
cdef struct color_c:
|
|
6
|
+
double r, g, b
|
|
7
|
+
|
|
8
|
+
cdef struct face_c:
|
|
9
|
+
int n
|
|
10
|
+
int* vertices
|
|
11
|
+
color_c color
|
|
12
|
+
|
|
13
|
+
cdef class Transformation:
|
|
14
|
+
cdef matrix
|
|
15
|
+
cdef double _matrix_data[12]
|
|
16
|
+
cdef object _svd
|
|
17
|
+
cpdef transform_point(self, x)
|
|
18
|
+
cpdef transform_vector(self, v)
|
|
19
|
+
cpdef transform_bounding_box(self, box)
|
|
20
|
+
cdef void transform_point_c(self, point_c* res, point_c P) noexcept
|
|
21
|
+
cdef void transform_vector_c(self, point_c* res, point_c P) noexcept
|