JuliaReach / LazySets.jl

Scalable symbolic-numeric set computations in Julia
https://juliareach.github.io/LazySets.jl/
Other
226 stars 32 forks source link

Add general polygon #3115

Open mforets opened 2 years ago

mforets commented 2 years ago

Add a struct that we can call Polygon that represents a possibly non-convex polygon. We can implement it as an array of line segments.

cc @mvanzulli

schillic commented 2 years ago

The line segments would store every vertex twice. A more efficient representation would be with only the vertices in the right order (Plots accepts the points both in clockwise and counter-clockwise order). A name could then be VPolygonNC ("NC" for "non-convex").

julia> vlist = [[0., 0], [0, 2], [2, 2], [2, 0], [1, 1]];
julia> vlistr = reverse(vlist);

# both orders of the vertices work
julia> plot([v[1] for v in vlist], [v[2] for v in vlist], seriestype=:shape)
julia> plot([v[1] for v in vlistr], [v[2] for v in vlistr], seriestype=:shape)

tooth

mvanzulli commented 2 years ago

Good point, thanks @schillic for the suggestion. Then we can add a method line_segments(non_convex_poly::VPolygonNC) that builds the vector of line segmentes. That would be desirable for my application in order to compute a ray_tracing method. I have included your comment in #3116.