-
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 #227 from JuliaReach/schillic/191
[WIP #191] HPolygon/HPolytope conversion
- Loading branch information
Showing
12 changed files
with
144 additions
and
39 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
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,20 @@ | ||
# Conversion between set representations | ||
|
||
This section of the manual lists the conversion functions between set | ||
representations. | ||
|
||
```@contents | ||
Pages = ["conversion.md"] | ||
Depth = 3 | ||
``` | ||
|
||
```@meta | ||
CurrentModule = LazySets | ||
DocTestSetup = quote | ||
using LazySets | ||
end | ||
``` | ||
|
||
```@docs | ||
convert | ||
``` |
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
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
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,85 @@ | ||
#= conversion between set types =# | ||
|
||
""" | ||
convert(::Type{HPOLYGON1}, P::HPOLYGON2) where | ||
{HPOLYGON1<:Union{HPolygon, HPolygonOpt}, HPOLYGON2<:AbstractHPolygon} | ||
Convert between polygon types in H-representation. | ||
### Input | ||
- `type` -- target type | ||
- `P` -- source polygon | ||
### Output | ||
The polygon represented as the target type. | ||
### Notes | ||
We need the `Union` type for `HPOLYGON1` because the target type must be | ||
concrete. | ||
""" | ||
function convert(::Type{HPOLYGON1}, | ||
P::HPOLYGON2) where {HPOLYGON1<:Union{HPolygon, HPolygonOpt}, | ||
HPOLYGON2<:AbstractHPolygon} | ||
return HPOLYGON1(P.constraints) | ||
end | ||
|
||
""" | ||
convert(::Type{HPolytope}, P::AbstractHPolygon) | ||
Convert from polygon in H-representation to polytope in H-representation. | ||
### Input | ||
- `type` -- target type | ||
- `P` -- source polygon | ||
### Output | ||
The polygon represented as 2D polytope. | ||
""" | ||
function convert(::Type{HPolytope}, P::AbstractHPolygon) | ||
return HPolytope(P.constraints) | ||
end | ||
|
||
""" | ||
convert(::Type{HPOLYGON}, P::HPolytope) where {HPOLYGON<:AbstractHPolygon} | ||
Convert from 2D polytope in H-representation to polygon in H-representation. | ||
### Input | ||
- `type` -- target type | ||
- `P` -- source polytope (must be 2D) | ||
### Output | ||
The 2D polytope represented as polygon. | ||
""" | ||
function convert(::Type{HPOLYGON}, | ||
P::HPolytope) where {HPOLYGON<:AbstractHPolygon} | ||
if dim(P) != 2 | ||
error("polytope must be 2D for conversion") | ||
end | ||
return HPOLYGON(P.constraints) | ||
end | ||
|
||
""" | ||
convert(::Type{Zonotope}, H::AbstractHyperrectangle{N}) where {N} | ||
Converts a hyperrectangular set to a zonotope. | ||
### Input | ||
- `Zonotope` | ||
- `H` -- hyperrectangular set | ||
### Output | ||
A zonotope. | ||
""" | ||
function convert(::Type{Zonotope}, H::AbstractHyperrectangle{N}) where {N} | ||
return Zonotope{N}(center(H), diagm(radius_hyperrectangle(H))) | ||
end |
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