Skip to content

Commit b570ac3

Browse files
author
Release Manager
committed
Trac #31640: 2d Bezier path does not plot in 3d
From https://ask.sagemath.org/question/56590/problem-with-plotting-a-3d- bezier-curve/ {{{ sage: p2d = [[(3.0,0.0),(3.0,0.13),(2.94,0.25),(2.8,0.35)], [(2.7,0.44),(2.6,0.5),(2.5,0.5)], [(2.36,0.5),(2.24,0.44),(2.14,0.35)], [(2.05,0.25),(2.0,0.13),(2.0,6.1e-17)]] sage: bp=bezier_path(p2d) sage: bp.plot3d() Traceback (most recent call last): /opt/sage/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8801)() 1298 try: -> 1299 n = self.pyobject() 1300 except TypeError: /opt/sage/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.pyobject (build/cythonized/sage/symbolic/expression.cpp:6136)() 586 if not is_a_numeric(self._gobj): --> 587 raise TypeError("self must be a numeric expression") 588 return py_object_from_numeric(self._gobj) TypeError: self must be a numeric expression During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) <ipython-input-6-37e325e9051f> in <module> ----> 1 bp.plot3d() /opt/sage/local/lib/python3.9/site-packages/sage/plot/graphics.py in plot3d(self, z, **kwds) 1279 """ 1280 from sage.plot.plot3d.base import Graphics3dGroup -> 1281 g = Graphics3dGroup([g.plot3d(**kwds) for g in self._objects]) 1282 if z: 1283 g = g.translate(0,0,z) /opt/sage/local/lib/python3.9/site-packages/sage/plot/graphics.py in <listcomp>(.0) 1279 """ 1280 from sage.plot.plot3d.base import Graphics3dGroup -> 1281 g = Graphics3dGroup([g.plot3d(**kwds) for g in self._objects]) 1282 if z: 1283 g = g.translate(0,0,z) /opt/sage/local/lib/python3.9/site-packages/sage/plot/bezier_path.py in plot3d(self, z, **kwds) 168 options = self._plot3d_options() 169 options.update(kwds) --> 170 return bezier3d([[(x,y,0) for x,y in self.path[i]] for i in range(len(self.path))], **options) 171 172 def _repr_(self): /opt/sage/local/lib/python3.9/site-packages/sage/misc/decorators.py in wrapper(*args, **kwds) 649 kwds[new_name] = kwds[old_name] 650 del kwds[old_name] --> 651 return func(*args, **kwds) 652 653 return wrapper /opt/sage/local/lib/python3.9/site-packages/sage/misc/decorators.py in wrapper(*args, **kwds) 489 options['__original_opts'] = kwds 490 options.update(kwds) --> 491 return func(*args, **options) 492 493 #Add the options specified by @options to the signature of the wrapped /opt/sage/local/lib/python3.9/site-packages/sage/plot/plot3d/shapes2.py in bezier3d(path, **options) 244 p2 = vector(curve[-2]) 245 p3 = vector(curve[-1]) --> 246 B = (1-t)**3*p0+3*t*(1-t)**2*p1+3*t**2*(1-t)*p2+t**3*p3 247 G += P3D.parametric_plot3d(list(B), (0, 1), color=options['color'], aspect_ratio=options['aspect_ratio'], thickness=options['thickness'], opacity=options['opacity']) 248 else: /opt/sage/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.__index__ (build/cythonized/sage/symbolic/expression.cpp:34734)() 5985 [0, 1, 2, 3, 4] 5986 """ -> 5987 return int(self._integer_()) 5988 5989 def iterator(self): /opt/sage/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._integer_ (build/cythonized/sage/symbolic/expression.cpp:8850)() 1299 n = self.pyobject() 1300 except TypeError: -> 1301 raise TypeError("unable to convert %r to an integer" % self) 1302 if isinstance(n, sage.rings.integer.Integer): 1303 return n TypeError: unable to convert -(t - 1)^3 to an integer }}} URL: https://trac.sagemath.org/31640 Reported by: vdelecroix Ticket author(s): Vincent Delecroix Reviewer(s): Frédéric Chapoton
2 parents bc54836 + 161d296 commit b570ac3

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=2cf3baba7d337a43d19e7b98ec2175d09b2b2a1d
3-
md5=8933ea22d6d4d30dbde6caeeace4fa64
4-
cksum=3069515967
2+
sha1=d37a1359ffb0a2a12c9fc2291799c7a70c2ab36d
3+
md5=59e93d77644d585380ce40498374ad77
4+
cksum=4017757244
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24a792f72807d9525d9c79a60cf135d034343e3c
1+
0ccc48bc712b5080b3117a13f33871c3dba45a29

src/sage/plot/plot3d/shapes2.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ def bezier3d(path, **options):
225225
sage: curve = bezier3d(path, thickness=5, color='blue')
226226
sage: curve
227227
Graphics3d Object
228+
229+
TESTS:
230+
231+
Check for :trac:`31640`::
232+
233+
sage: p2d = [[(3,0.0),(3,0.13),(2,0.2),(2,0.3)], [(2.7,0.4),(2.6,0.5),(2.5,0.5)], [(2.3,0.5),(2.2,0.4),(2.1,0.3)]]
234+
sage: bp = bezier_path(p2d)
235+
sage: bp.plot3d()
236+
Graphics3d Object
237+
238+
sage: p3d = p3d = [[(3,0,0),(3,0.1,0),(2.9,0.2,0),(2.8,0.3,0)], [(2.7,0.4,0),(2,0.5,0),(2.5,0.5,0)], [(2.3,0.5,0),(2.2,0.4,0),(2.1,0.3,0)]]
239+
sage: bezier3d(p3d)
240+
Graphics3d Object
228241
"""
229242
from . import parametric_plot3d as P3D
230243
from sage.modules.free_module_element import vector
@@ -247,7 +260,7 @@ def bezier3d(path, **options):
247260
G += P3D.parametric_plot3d(list(B), (0, 1), color=options['color'], aspect_ratio=options['aspect_ratio'], thickness=options['thickness'], opacity=options['opacity'])
248261
else:
249262
G += line3d([p0,curve[0]], color=options['color'], thickness=options['thickness'], opacity=options['opacity'])
250-
p0 = curve[-1]
263+
p0 = vector(curve[-1])
251264
return G
252265

253266
@rename_keyword(alpha='opacity')

0 commit comments

Comments
 (0)