ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 26 Jan 2017 19:21:42 +0100How does one use the qhull optional package?https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/Has anyone used the qhull optional package? I'm not so sure on how to use it. Is there a tutorial on this?Tue, 18 Jun 2013 21:22:00 +0200https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/Comment by ppurka for <p>Has anyone used the qhull optional package? I'm not so sure on how to use it. Is there a tutorial on this?</p>
https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?comment=17474#post-id-17474Sorry. Deleted my post. I misread your question about installing, whereas you asked about *using*.Wed, 19 Jun 2013 11:44:10 +0200https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?comment=17474#post-id-17474Answer by tmonteil for <p>Has anyone used the qhull optional package? I'm not so sure on how to use it. Is there a tutorial on this?</p>
https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?answer=15106#post-id-15106First, you can install it by typing:
$ sage -i qhull
Then, i do not think that there in an interface with `qhull` inside Sage. So, you have to use it from a shell, as if you installed it on your OS:
$ sage -sh
To get help and examples, just type:
(sage-sh) user@machine:~$ qhull
And then, you can try one of the examples:
(sage-sh) user@machine:~$ rbox y 1000 W0 | qhull
Convex hull of 1004 points in 3-d:
Number of vertices: 4
Number of facets: 4
Statistics for: rbox y 1000 W0 | qhull
Number of points processed: 4
Number of hyperplanes created: 5
Number of distance tests for qhull: 11001
CPU seconds to compute hull (after input): 0
To get informations about `rbox`, just type:
(sage-sh) user@machine:~$ rbox
**EDIT** : `qhull` is shipped with `scipy` (and also with `matplotlib` from version 1.4), so you could benefit from [their Cython interface](https://github.com/scipy/scipy/blob/master/scipy/spatial/qhull.pyx) to use `qhull` features within Sage (Delaunay triangulation, Voronoi tesselation, convex hull), see [this page](http://docs.scipy.org/doc/scipy-0.14.0/reference/spatial.html#delaunay-triangulation-convex-hulls-and-voronoi-diagrams).
Wed, 19 Jun 2013 13:21:48 +0200https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?answer=15106#post-id-15106Comment by torrho for <p>First, you can install it by typing:</p>
<pre><code>$ sage -i qhull
</code></pre>
<p>Then, i do not think that there in an interface with <code>qhull</code> inside Sage. So, you have to use it from a shell, as if you installed it on your OS:</p>
<pre><code>$ sage -sh
</code></pre>
<p>To get help and examples, just type:</p>
<pre><code>(sage-sh) user@machine:~$ qhull
</code></pre>
<p>And then, you can try one of the examples:</p>
<pre><code>(sage-sh) user@machine:~$ rbox y 1000 W0 | qhull
Convex hull of 1004 points in 3-d:
Number of vertices: 4
Number of facets: 4
Statistics for: rbox y 1000 W0 | qhull
Number of points processed: 4
Number of hyperplanes created: 5
Number of distance tests for qhull: 11001
CPU seconds to compute hull (after input): 0
</code></pre>
<p>To get informations about <code>rbox</code>, just type:</p>
<pre><code>(sage-sh) user@machine:~$ rbox
</code></pre>
<p><strong>EDIT</strong> : <code>qhull</code> is shipped with <code>scipy</code> (and also with <code>matplotlib</code> from version 1.4), so you could benefit from <a href="https://github.com/scipy/scipy/blob/master/scipy/spatial/qhull.pyx">their Cython interface</a> to use <code>qhull</code> features within Sage (Delaunay triangulation, Voronoi tesselation, convex hull), see <a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/spatial.html#delaunay-triangulation-convex-hulls-and-voronoi-diagrams">this page</a>.</p>
https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?comment=17472#post-id-17472I have no idea why I didn't think of that. I was going nuts over this. Thanks!Wed, 19 Jun 2013 18:37:49 +0200https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?comment=17472#post-id-17472Answer by pang for <p>Has anyone used the qhull optional package? I'm not so sure on how to use it. Is there a tutorial on this?</p>
https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?answer=36402#post-id-36402I'll expand on tmonteil's last comment: there is an [interface to qhull included on scipy](http://docs.scipy.org/doc/scipy-0.14.0/reference/spatial.html#delaunay-triangulation-convex-hulls-and-voronoi-diagrams)!
For example, this code computes the hull of a random set of **2D** points:
import numpy as np
from scipy.spatial import ConvexHull
points = np.random.rand(30, 2) # 30 random points in 2-D
hull = ConvexHull(points)
and this code plots it:
my_plot = point2d(points)
for simplex in hull.simplices:
my_plot += line2d([points[v,:] for v in simplex])
my_plot
While this code computes the hull of a random set of **3D** points:
import numpy as np
from scipy.spatial import ConvexHull
points = np.random.rand(30, 3) # 30 random points in 3-D
hull = ConvexHull(points)
and this code plots it:
my_plot = point3d(points)
for simplex in hull.simplices:
my_plot += line3d([points[simplex[-1],:]]+[points[v,:] for v in simplex])
my_plotThu, 26 Jan 2017 19:21:42 +0100https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/?answer=36402#post-id-36402