Opened 8 months ago

Closed 7 months ago

#31640 closed defect (fixed)

2d Bezier path does not plot in 3d

Reported by: vdelecroix Owned by:
Priority: blocker Milestone: sage-9.3
Component: graphics Keywords: bug
Cc: Merged in:
Authors: Vincent Delecroix Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 161d296 (Commits, GitHub, GitLab) Commit: 161d29659e1b234dd5bb01434918f7ae2a879328
Dependencies: Stopgaps:

Status badges

Description

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

Change History (6)

comment:1 Changed 8 months ago by vdelecroix

  • Authors set to Vincent Delecroix
  • Branch set to u/vdelecroix/31640
  • Commit set to 740b6296227aa12d05023f51322718ff7bea9e06
  • Status changed from new to needs_review

New commits:

0b387f730518: raise errors in eigenspace/eigenvector in more cases
740b62931640: fix bezier curves plotting in 3d

comment:2 Changed 8 months ago by git

  • Commit changed from 740b6296227aa12d05023f51322718ff7bea9e06 to 161d29659e1b234dd5bb01434918f7ae2a879328

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

161d29631640: fix bezier curves plotting in 3d

comment:3 Changed 8 months ago by chapoton

  • Milestone changed from sage-9.3 to sage-9.4
  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok

comment:4 Changed 8 months ago by vdelecroix

This is a bug fix. Why don't we make it for 9.3?

comment:5 Changed 8 months ago by vdelecroix

  • Keywords bug added
  • Milestone changed from sage-9.4 to sage-9.3
  • Priority changed from major to blocker

Let us try to squeezee in

comment:6 Changed 7 months ago by vbraun

  • Branch changed from u/vdelecroix/31640 to 161d29659e1b234dd5bb01434918f7ae2a879328
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.