-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3116 from mvanzulli/master
Include non-convex polygon struct `VPolygonNC` ✳️
- Loading branch information
Showing
8 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```@docs | ||
VPolygonNC | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export VPolygonNC | ||
|
||
""" | ||
VPolygonNC{N, VN<:AbstractVector{N}} <: LazySet{N} | ||
Type that represents a non-convex polygon by its vertices. | ||
### Fields | ||
- `vertices` -- the list of vertices | ||
### Examples | ||
A non-convex polygon in vertex representation can be constructed by passing the list of | ||
vertices. For example, we can build a tooth: | ||
```jldoctest polygon_v_ncrep | ||
julia> NCP = VPolygonNC( [[0., 0], [0, 2], [2, 2], [2, 0], [1, 1]]); | ||
julia> NCP.vertices | ||
5-element Vector{Vector{Float64}}: | ||
[0.0, 0.0] | ||
[0.0, 2.0] | ||
[2.0, 2.0] | ||
[2.0, 0.0] | ||
[1.0, 1.0] | ||
``` | ||
""" | ||
struct VPolygonNC{N, VN<:AbstractVector{N}} <: LazySet{N} | ||
vertices::Vector{VN} | ||
|
||
function VPolygonNC(vertices::Vector{VN}) where {N, VN<:AbstractVector{N}} | ||
return new{N, VN}(vertices) | ||
end | ||
end | ||
|
||
# constructor with empty vertices list | ||
VPolygonNC{N}() where {N} = VPolygonNC(Vector{Vector{N}}()) | ||
|
||
# constructor with no vertices of type Float64 | ||
VPolygonNC() = VPolygonNC{Float64}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# default Float64 constructors | ||
@test VPolygonNC() isa VPolygonNC{Float64, Vector{Float64}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters