Skip to content

Commit

Permalink
Merge pull request #3466 from JuliaReach/schillic/convert_poly
Browse files Browse the repository at this point in the history
More convert methods for HPolytope/HPolyhedron
  • Loading branch information
schillic authored Mar 19, 2024
2 parents 41f4c75 + 4f6030e commit ac947ba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ function convert(::Type{HPolytope}, X::LazySet)
return HPolytope(constraints_list(X))
end

function convert(::Type{HPolytope{N,VT}}, X::LazySet) where {N,VT}
if !isboundedtype(typeof(X)) || !is_polyhedral(X)
error("conversion to `HPolytope` requires a polytopic set")
end
return HPolytope([HalfSpace(VT(c.a), N(c.b)) for c in constraints_list(X)])
end

"""
convert(::Type{HPolyhedron}, X::LazySet)
Expand All @@ -99,12 +106,11 @@ function convert(::Type{HPolyhedron}, X::LazySet)
return HPolyhedron(constraints_list(X))
end

# conversion of a lazyset to a polyhedron with dense normal vectors
function convert(::Type{HPolyhedron{N,Vector{N}}}, X::LazySet) where {N}
function convert(::Type{HPolyhedron{N,VT}}, X::LazySet) where {N,VT}
if !is_polyhedral(X)
error("conversion to `HPolyhedron` requires a polyhedral set")
end
return HPolyhedron([HalfSpace(Vector(c.a), c.b) for c in constraints(X)])
return HPolyhedron([HalfSpace(VT(c.a), N(c.b)) for c in constraints(X)])
end

"""
Expand Down

0 comments on commit ac947ba

Please sign in to comment.