Skip to content

Commit

Permalink
Merge pull request #596 from JuliaReach/mforets/595
Browse files Browse the repository at this point in the history
#595 - Polytopes intersect should be intersection
  • Loading branch information
mforets authored Aug 30, 2018
2 parents 0be3305 + 9ba47d6 commit d2108cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions docs/src/man/concrete_polyhedra.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ product.
The dual representation as a list of vertices can be obtained with the
`vertices_list` function.

For example, the intersection of two polytopes is performed with the `intersect`
method.
For example, the concrete intersection of two polytopes is performed with the
`intersection` method.

```@example concrete_polyhedra
E = Ellipsoid(ones(2), diagm([2.0, 0.5]))
Expand All @@ -108,7 +108,7 @@ polyoverapprox(x) = HPolytope(overapproximate(x, 1e-3).constraints)
Epoly = polyoverapprox(E)
Bpoly = polyoverapprox(B)
X = intersect(Epoly, Bpoly)
X = intersection(Epoly, Bpoly)
plot(E, 1e-3, aspectratio=1, alpha=0.4)
plot!(B, 1e-3, alpha=0.4)
Expand Down
16 changes: 8 additions & 8 deletions src/HPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ import Polyhedra:polyhedron, SimpleHRepresentation, SimpleHRepresentation,
hcartesianproduct,
points

export intersect, convex_hull, cartesian_product, vertices_list
export intersection, convex_hull, cartesian_product, vertices_list

# HPolytope from an HRep
function HPolytope(P::HRep{N, T}, backend=CDDLib.CDDLibrary()) where {N, T}
Expand Down Expand Up @@ -246,9 +246,9 @@ function polyhedron(P::HPolytope{N}, backend=CDDLib.CDDLibrary()) where {N}
end

"""
intersect(P1::HPolytope{N}, P2::HPolytope{N};
[backend]=CDDLib.CDDLibrary(),
[prunefunc]=removehredundancy!)::HPolytope{N} where {N<:Real}
intersection(P1::HPolytope{N}, P2::HPolytope{N};
[backend]=CDDLib.CDDLibrary(),
[prunefunc]=removehredundancy!)::HPolytope{N} where {N<:Real}
Compute the intersection of two polytopes in H-representation.
Expand All @@ -266,13 +266,13 @@ Compute the intersection of two polytopes in H-representation.
The `HPolytope` obtained by the intersection of `P1` and `P2`.
"""
function intersect(P1::HPolytope{N}, P2::HPolytope{N};
backend=CDDLib.CDDLibrary(),
prunefunc=removehredundancy!)::HPolytope{N} where {N<:Real}
function intersection(P1::HPolytope{N}, P2::HPolytope{N};
backend=CDDLib.CDDLibrary(),
prunefunc=removehredundancy!)::HPolytope{N} where {N<:Real}

P1 = polyhedron(P1, backend)
P2 = polyhedron(P2, backend)
Pint = intersect(P1, P2)
Pint = Polyhedra.intersect(P1, P2)
prunefunc(Pint)
return HPolytope(Pint)
end
Expand Down
16 changes: 8 additions & 8 deletions src/VPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import Polyhedra:polyhedron, SimpleHRepresentation, SimpleVRepresentation,
convexhull,
hcartesianproduct

export intersect, convex_hull, cartesian_product, vertices_list
export intersection, convex_hull, cartesian_product, vertices_list

# VPolytope from a VRep
function VPolytope(P::VRep{N, T}, backend=CDDLib.CDDLibrary()) where {N, T}
Expand Down Expand Up @@ -162,9 +162,9 @@ function polyhedron(P::VPolytope{N}, backend=CDDLib.CDDLibrary()) where {N}
end

"""
intersect(P1::VPolytope{N}, P2::VPolytope{N};
[backend]=CDDLib.CDDLibrary(),
[prunefunc]=removehredundancy!)::VPolytope{N} where {N<:Real}
intersection(P1::VPolytope{N}, P2::VPolytope{N};
[backend]=CDDLib.CDDLibrary(),
[prunefunc]=removehredundancy!)::VPolytope{N} where {N<:Real}
Compute the intersection of two polytopes in V-representation.
Expand All @@ -182,13 +182,13 @@ Compute the intersection of two polytopes in V-representation.
The `VPolytope` obtained by the intersection of `P1` and `P2`.
"""
function intersect(P1::VPolytope{N}, P2::VPolytope{N};
backend=CDDLib.CDDLibrary(),
prunefunc=removehredundancy!)::VPolytope{N} where {N<:Real}
function intersection(P1::VPolytope{N}, P2::VPolytope{N};
backend=CDDLib.CDDLibrary(),
prunefunc=removehredundancy!)::VPolytope{N} where {N<:Real}

P1 = polyhedron(P1, backend)
P2 = polyhedron(P2, backend)
Pint = intersect(P1, P2)
Pint = Polyhedra.intersect(P1, P2)
prunefunc(Pint)
return VPolytope(Pint)
end
Expand Down
4 changes: 2 additions & 2 deletions test/unit_Polytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if test_suite_polyhedra
A = [N(0) N(-1); N(-1) N(0); N(1) N(1)]
b = N[-0.25, -0.25, -0]
p2 = HPolytope(A, b)
cap = intersect(p1, p2)
cap = intersection(p1, p2)
# currently broken, see #565

# convex hull
Expand Down Expand Up @@ -135,7 +135,7 @@ if test_suite_polyhedra
# intersection
p1 = VPolytope(vertices_list(BallInf(N[0, 0], N(1))))
p2 = VPolytope(vertices_list(BallInf(N[2, 2], N(1))))
cap = intersect(p1, p2)
cap = intersection(p1, p2)
@test vertices_list(cap) == [N[1, 1]]

# convex hull
Expand Down

0 comments on commit d2108cf

Please sign in to comment.