Ask Your Question

slabbe's profile - activity

2018-07-03 09:57:47 -0600 received badge  Famous Question (source)
2017-01-26 04:36:26 -0600 received badge  Nice Answer (source)
2016-12-23 07:51:38 -0600 received badge  Notable Question (source)
2016-05-04 22:20:15 -0600 received badge  Popular Question (source)
2014-06-29 14:51:57 -0600 received badge  Popular Question (source)
2014-01-24 01:10:40 -0600 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 12:41:06 -0600 received badge  Teacher (source)
2013-12-19 12:41:06 -0600 received badge  Self-Learner (source)
2013-12-19 03:06:50 -0600 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-08 20:45:48 -0600 received badge  Student (source)
2013-12-04 21:25:47 -0600 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...