Skip to content

Commit

Permalink
#58 - added common functions for Polygonal
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Dec 14, 2017
1 parent fa02f72 commit 4dad475
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 25 deletions.
26 changes: 21 additions & 5 deletions src/HPolygonal.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Base.∈

export HPolygonal,
addconstraint!,
tovrep,
vertices_list
addconstraint!

"""
HPolygonal{N<:Real} <: Polygonal{N}
Expand Down Expand Up @@ -84,7 +82,7 @@ end


"""
tovrep(P::HPolygonal)::VPolygon
tovrep(P::HPolygonal{N})::VPolygon{N} where {N<:Real}
Build a vertex representation of the given polygon.
Expand All @@ -96,11 +94,29 @@ Build a vertex representation of the given polygon.
The same polygon but in vertex representation, a `VPolygon`.
"""
function tovrep(P::HPolygonal)::VPolygon
function tovrep(P::HPolygonal{N})::VPolygon{N} where {N<:Real}
return VPolygon(vertices_list(P))
end


"""
tohrep(P::HPolygonal{N})::HPolygonal{N} where {N<:Real}
Build a contraint representation of the given polygon.
### Input
- `P` -- polygon in constraint representation
### Output
The identity, i.e., the same polygon instance.
"""
function tohrep(P::HPolygonal{N})::HPolygonal{N} where {N<:Real}
return P
end


"""
vertices_list(P::HPolygonal{N})::Vector{Vector{N}} where {N<:Real}
Expand Down
3 changes: 2 additions & 1 deletion src/PointSymmetric_Polytopic.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export PointSymmetric_Polytopic
export PointSymmetric_Polytopic,
vertices_list

"""
PointSymmetric_Polytopic{N<:Real} <: PointSymmetric{N}
Expand Down
4 changes: 3 additions & 1 deletion src/Polygonal.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export Polygonal
export Polygonal,
tohrep,
tovrep

"""
Polygonal{N<:Real} <: Polytopic{N}
Expand Down
3 changes: 2 additions & 1 deletion src/Polytopic.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export Polytopic
export Polytopic,
vertices_list

"""
Polytopic{N<:Real} <: LazySet
Expand Down
51 changes: 34 additions & 17 deletions src/VPolygon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ struct VPolygon{N<:Real} <: Polygonal{N}
end
end

"""
dim(P::VPolygon)::Int
Return the dimension of a polygon in vertex representation.
### Input
- `P` -- polygon in vertex representation
### Output
The ambient dimension of the polygon.
"""
function dim(P::VPolygon)::Int
return 2
end

"""
σ(d::AbstractVector{<:Real}, P::VPolygon{N})::Vector{N} where {N<:Real}
Expand Down Expand Up @@ -98,6 +81,40 @@ function σ(d::AbstractVector{<:Real}, P::VPolygon{N})::Vector{N} where {N<:Real
return P.vertices_list[i_max]
end

"""
tovrep(P::VPolygon{N})::VPolygon{N} where {N<:Real}
Build a vertex representation of the given polygon.
### Input
- `P` -- polygon in vertex representation
### Output
The identity, i.e., the same polygon instance.
"""
function tovrep(P::VPolygon{N})::VPolygon{N} where {N<:Real}
return P
end

"""
tohrep(P::VPolygon{N})::HPolygonal{N} where {N<:Real}
Build a contraint representation of the given polygon.
### Input
- `P` -- polygon in vertex representation
### Output
The same polygon but in contraint representation, an `HPolygonal`.
"""
function tohrep(P::VPolygon{N})::HPolygonal{N} where {N<:Real}
error("this function is not implemented yet, see issue #5")
end

"""
vertices_list(P::VPolygon{N})::Vector{Vector{N}} where {N<:Real}
Expand Down

0 comments on commit 4dad475

Please sign in to comment.