From bd5126d9797102585a5c019c2a6cae290f6d340b Mon Sep 17 00:00:00 2001 From: mforets Date: Sat, 3 Mar 2018 08:28:48 -0300 Subject: [PATCH 1/4] postprocess 2D vertices list with a convex hull --- src/plot_recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plot_recipes.jl b/src/plot_recipes.jl index 91473391da..b2a3a27c19 100644 --- a/src/plot_recipes.jl +++ b/src/plot_recipes.jl @@ -30,7 +30,7 @@ plotting singletons. color="blue", label="", grid=true, alpha=0.5) P = Approximations.overapproximate(S) - vlist = hcat(vertices_list(P)...).' + vlist = hcat(convex_hull(vertices_list(P))...).' (x, y) = vlist[:, 1], vlist[:, 2] seriestype := norm(vlist[1, :] - vlist[2, :]) ≈ 0 ? :scatter : :shape From 5332d9617dacaf86d4caa666bfff8b2da620eeea Mon Sep 17 00:00:00 2001 From: mforets Date: Sat, 3 Mar 2018 08:34:07 -0300 Subject: [PATCH 2/4] explain plot_lazyset algorithm --- src/plot_recipes.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plot_recipes.jl b/src/plot_recipes.jl index b2a3a27c19..acdbeb7fc9 100644 --- a/src/plot_recipes.jl +++ b/src/plot_recipes.jl @@ -19,6 +19,13 @@ julia> B = BallInf(ones(2), 0.1) julia> plot(2.0 * B) ``` +### Algorithm + +For any 2D lazy set we compute its box overapproximation, followed by the list of +vertices. A post-processing `convex_hull` is applied to the vertices list; +this ensures that the shaded area inside the convex hull of the vertices is covered +correctly. + ### Notes This recipe detects if the axis-aligned approximation is such that the first two From 473f06bda1ca4c3b33d3cd417b00b40e23b5dd5d Mon Sep 17 00:00:00 2001 From: mforets Date: Sat, 3 Mar 2018 08:47:48 -0300 Subject: [PATCH 3/4] update vector version too --- src/plot_recipes.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plot_recipes.jl b/src/plot_recipes.jl index acdbeb7fc9..e06c7efbe9 100644 --- a/src/plot_recipes.jl +++ b/src/plot_recipes.jl @@ -63,6 +63,13 @@ julia> B1 = BallInf(zeros(2), 0.4) julia> B2 = BallInf(ones(2), 0.4) julia> plot([B1, B2]) ``` + +### Algorithm + +For each 2D lazy set in the array we compute its box overapproximation, followed +by the list of vertices. A post-processing `convex_hull` is applied to the vertices list; +this ensures that the shaded area inside the convex hull of the vertices is covered +correctly. """ @recipe function plot_lazyset(arr::Vector{<:LazySet}; seriescolor="blue", label="", grid=true, @@ -72,7 +79,7 @@ julia> plot([B1, B2]) for S in arr Pi = Approximations.overapproximate(S) - vlist = hcat(vertices_list(Pi)...).' + vlist = hcat(convex_hull(vertices_list(P))...).' @series (x, y) = vlist[:, 1], vlist[:, 2] end end From 2c123d2a55ffc8ff3aac938efe5a0ac01dd03e3a Mon Sep 17 00:00:00 2001 From: mforets Date: Sat, 3 Mar 2018 08:53:00 -0300 Subject: [PATCH 4/4] P -> Pi --- src/plot_recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plot_recipes.jl b/src/plot_recipes.jl index e06c7efbe9..da807f20c6 100644 --- a/src/plot_recipes.jl +++ b/src/plot_recipes.jl @@ -79,7 +79,7 @@ correctly. for S in arr Pi = Approximations.overapproximate(S) - vlist = hcat(convex_hull(vertices_list(P))...).' + vlist = hcat(convex_hull(vertices_list(Pi))...).' @series (x, y) = vlist[:, 1], vlist[:, 2] end end