Skip to content

Commit

Permalink
check dimensionality in VPolygon constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Nov 30, 2024
1 parent fd7ca92 commit cb8fec3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Sets/VPolygon/VPolygon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct VPolygon{N,VN<:AbstractVector{N}} <: AbstractPolygon{N}
function VPolygon(vertices::Vector{VN};
apply_convex_hull::Bool=true,
algorithm::String="monotone_chain") where {N,VN<:AbstractVector{N}}
@assert all(v -> length(v) == 2, vertices)
if apply_convex_hull
vertices = convex_hull(vertices; algorithm=algorithm)
end
Expand Down
3 changes: 3 additions & 0 deletions test/Sets/Polygon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ for N in [Float64, Float32, Rational{Int}]
constraints_list(HPolygonOpt(A, b)) ==
[HalfSpace(N[2, 0], N(-1)), HalfSpace(N[1, 3], N(1))]

# constructor for V-rep
@test_throws AssertionError VPolygon([N[0, 0], N[1]])

# conversion to optimized polygon
po = convert(HPolygonOpt, p)
# conversion back
Expand Down

0 comments on commit cb8fec3

Please sign in to comment.