Skip to content

Commit 31d5e73

Browse files
authored
Merge pull request #144 from mforets/mforets/convexhull
Update operations notebook
2 parents b9b4d8b + 28ee080 commit 31d5e73

File tree

1 file changed

+95
-6
lines changed

1 file changed

+95
-6
lines changed

examples/operations.ipynb

Lines changed: 95 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"cell_type": "markdown",
187187
"metadata": {},
188188
"source": [
189-
"On the other hand, `Pint` is contructed from its H-representation hence its V-representation had not been computed yet."
189+
"On the other hand, `Pint` is constructed from its H-representation hence its V-representation has not been computed yet."
190190
]
191191
},
192192
{
@@ -720,25 +720,114 @@
720720
"hrepiscomputed(P1), hrepiscomputed(P2), hrepiscomputed(Pint)"
721721
]
722722
},
723+
{
724+
"cell_type": "markdown",
725+
"metadata": {},
726+
"source": [
727+
"Let us note that the `convexhull` of a V-representation contains points and rays and represents the convex hull\n",
728+
"of the points together with the conic hull of the rays. So, `convexhull(P1, P2)` does the union of the vertices:"
729+
]
730+
},
723731
{
724732
"cell_type": "code",
725-
"execution_count": null,
733+
"execution_count": 2,
726734
"metadata": {},
727-
"outputs": [],
728-
"source": []
735+
"outputs": [
736+
{
737+
"data": {
738+
"text/plain": [
739+
"Polyhedron CDDLib.Polyhedron{Float64}:\n",
740+
"15-element iterator of Array{Float64,1}:\n",
741+
" [0.965939, -0.408821]\n",
742+
" [0.0423453, -2.35475]\n",
743+
" [0.445098, 0.496043]\n",
744+
" [-0.503593, -0.643319]\n",
745+
" [0.275412, 0.958958]\n",
746+
" [1.52787, 0.765889]\n",
747+
" [2.32907, 0.508292]\n",
748+
" [0.976168, -0.213605]\n",
749+
" [-1.2088, 0.561409]\n",
750+
" [0.0899901, -1.99332]\n",
751+
" [-0.436715, -0.0207767]\n",
752+
" [-0.915581, -0.307397]\n",
753+
" [0.162809, -0.899802]\n",
754+
" [1.89527, 0.417177]\n",
755+
" [-1.19564, 0.680285]"
756+
]
757+
},
758+
"execution_count": 2,
759+
"metadata": {},
760+
"output_type": "execute_result"
761+
}
762+
],
763+
"source": [
764+
"# each of Q1 and Q2 has 15 vertices\n",
765+
"Q1 = polyhedron(vrep(randn(15, 2)), CDDLib.Library())\n",
766+
"Q2 = polyhedron(vrep(randn(15, 2)), CDDLib.Library())"
767+
]
768+
},
769+
{
770+
"cell_type": "code",
771+
"execution_count": 3,
772+
"metadata": {},
773+
"outputs": [
774+
{
775+
"data": {
776+
"text/plain": [
777+
"30"
778+
]
779+
},
780+
"execution_count": 3,
781+
"metadata": {},
782+
"output_type": "execute_result"
783+
}
784+
],
785+
"source": [
786+
"# check that their convex hull has 30 vertices\n",
787+
"Qch = convexhull(Q1, Q2)\n",
788+
"npoints(Qch)"
789+
]
790+
},
791+
{
792+
"cell_type": "markdown",
793+
"metadata": {},
794+
"source": [
795+
"However, if we want to remove the redundant points we can use `removevredundancy!`:"
796+
]
797+
},
798+
{
799+
"cell_type": "code",
800+
"execution_count": 4,
801+
"metadata": {},
802+
"outputs": [
803+
{
804+
"data": {
805+
"text/plain": [
806+
"9"
807+
]
808+
},
809+
"execution_count": 4,
810+
"metadata": {},
811+
"output_type": "execute_result"
812+
}
813+
],
814+
"source": [
815+
"removevredundancy!(Qch)\n",
816+
"npoints(Qch)"
817+
]
729818
}
730819
],
731820
"metadata": {
732821
"kernelspec": {
733-
"display_name": "Julia 1.0.1",
822+
"display_name": "Julia 1.0.2",
734823
"language": "julia",
735824
"name": "julia-1.0"
736825
},
737826
"language_info": {
738827
"file_extension": ".jl",
739828
"mimetype": "application/julia",
740829
"name": "julia",
741-
"version": "1.0.1"
830+
"version": "1.0.2"
742831
}
743832
},
744833
"nbformat": 4,

0 commit comments

Comments
 (0)