Ask Your Question

slabbe's profile - activity

2018-07-03 16:57:47 +0200 received badge  Famous Question (source)
2017-01-26 11:36:26 +0200 received badge  Nice Answer (source)
2016-12-23 14:51:38 +0200 received badge  Notable Question (source)
2016-05-05 05:20:15 +0200 received badge  Popular Question (source)
2014-06-29 21:51:57 +0200 received badge  Popular Question (source)
2014-01-24 08:10:40 +0200 asked a question How to compute the asymptotics of a polynomial fraction?

How to compute the asymptotic of the coefficients of the Laurent serie of a polynomial fraction?

2013-12-19 19:41:06 +0200 received badge  Self-Learner (source)
2013-12-19 19:41:06 +0200 received badge  Teacher (source)
2013-12-19 10:06:50 +0200 answered a question How to compute the convex hull of a set of points in the plane?

Somebody just gave me the following link: sage.geometry.polyhedron.plot.cyclic_sort_vertices_2d

2013-12-09 03:45:48 +0200 received badge  Student (source)
2013-12-05 04:25:47 +0200 asked a question How to compute the convex hull of a set of points in the plane?

How to compute the convex hull of a set of points in the plane and obtain the resulting vertices as a list in the good order?

The following does not work because the vertices are returned in any order. You can confirm this by drawing the polygon of them.

sage: p = Polyhedron(vertices = [(random(),random()) for _ in range(10)])
sage: p.vertices()
(A vertex at (0.02426982921, 0.8569166506),
 A vertex at (0.9906153404, 0.5055452233),
 A vertex at (0.8056807969, 0.9885901971),
 A vertex at (0.02148155632, 0.6201313201),
 A vertex at (0.8789116179, 0.4107095649),
 A vertex at (0.1045180727, 0.2367290111))
sage: polygon(p.vertices())

The function p.plot() does show the polyhedra correctly, so I found the following method to get the list I want :

sage: good = p.plot()._objects[-1]
sage: good
Polygon defined by 6 points
sage: I_want_this_list = zip(good.xdata, good.ydata)
sage: polygon(I_want_this_list)

There should be a cleaner way to get my list no? In general, the polygon might not be stored in the last item of the list p.plot()._objects...