Skip to content

Commit a876c7c

Browse files
authored
Merge pull request #3658 from JuliaReach/schillic/vpolygon
Check dimensionality in `VPolygon` constructor
2 parents c88d0e8 + cb8fec3 commit a876c7c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Sets/VPolygon/VPolygon.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct VPolygon{N,VN<:AbstractVector{N}} <: AbstractPolygon{N}
5656
function VPolygon(vertices::Vector{VN};
5757
apply_convex_hull::Bool=true,
5858
algorithm::String="monotone_chain") where {N,VN<:AbstractVector{N}}
59+
@assert all(v -> length(v) == 2, vertices)
5960
if apply_convex_hull
6061
vertices = convex_hull(vertices; algorithm=algorithm)
6162
end

test/Sets/Polygon.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ for N in [Float64, Float32, Rational{Int}]
5252
constraints_list(HPolygonOpt(A, b)) ==
5353
[HalfSpace(N[2, 0], N(-1)), HalfSpace(N[1, 3], N(1))]
5454

55+
# constructor for V-rep
56+
@test_throws AssertionError VPolygon([N[0, 0], N[1]])
57+
5558
# conversion to optimized polygon
5659
po = convert(HPolygonOpt, p)
5760
# conversion back

0 commit comments

Comments
 (0)