Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add general polygon #3115

Open
mforets opened this issue Oct 7, 2022 · 2 comments
Open

Add general polygon #3115

mforets opened this issue Oct 7, 2022 · 2 comments

Comments

@mforets
Copy link
Member

mforets commented Oct 7, 2022

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
Copy link
Member

schillic commented Oct 8, 2022

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
Copy link
Contributor

mvanzulli commented Oct 8, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants