Skip to content

Commit

Permalink
move tests and add test in 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Apr 7, 2023
1 parent 4662b49 commit 6d946ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
26 changes: 26 additions & 0 deletions test/ConcreteOperations/minkowski_difference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,30 @@ for N in [Float64, Float32, Rational{Int}]
Zs3 = Zonotope(N[0, 0], N[2 0; -1/2 1/2])
D3 = minkowski_difference(Zm, Zs3)
@test D3 isa EmptySet{N} && dim(D3) == 2

# zonotope in 3D
Zm = Zonotope(N[1, 1, 1], N[1 0 0; 0 1 0; 0 0 1])
Zs = Zonotope(N[0, 0, 1], hcat(N[1/2; 0; 0]))
D = minkowski_difference(Zm, Zs)
@test isequivalent(D, HPolytope([
HalfSpace(N[0, 0, 1], N(1)), HalfSpace(N[0, 0, -1], N(1)),
HalfSpace(N[0, 1, 0], N(2)), HalfSpace(N[0, -1, 0], N(0)),
HalfSpace(N[1, 0, 0], N(3/2)), HalfSpace(N[-1, 0, 0], N(-1/2))]))
if N == Float64
@test isequivalent(D, Zonotope(N[1, 1, 0], N[1/2 0 0; 0 1 0; 0 0 1]))
end
end

for N in [Float64]
if test_suite_polyhedra
# concrete Minkowski difference for unbounded P (HPolyhedron)
mx1 = N(2)
mx2 = N(5)
P3 = HPolyhedron(N[mx1 0; 0 mx2], N[3, 3])
radius = 2
Q3 = Ball1(N[0, 0], N(radius))
C3 = minkowski_difference(P3, Q3)
C3_res = HPolyhedron(N[mx1 0; 0 mx2], N[3 - mx1*radius, 3 - mx2*radius])
@test C3 C3_res && C3_res C3
end
end
16 changes: 0 additions & 16 deletions test/Sets/Polytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -502,22 +502,6 @@ for N in [Float64]
twoB = 2.0*B
@test X twoB && twoB X

# concrete minkowski difference (special case, where A == A ⊖ B ⊕ B)
A2 = BallInf(N[0, 0], N(5))
B2 = BallInf(N[0, 0], N(2))
C2 = minkowski_difference(A2,B2)
@test C2 BallInf(N[0, 0], N(3)) && BallInf(N[0, 0], N(3)) C2

# concrete Minkowski difference for unbounded P (HPolyhedron)
mx1 = N(2)
mx2 = N(5)
P3 = HPolyhedron(N[mx1 0; 0 mx2], N[3, 3])
radius = 2
Q3 = Ball1(N[0, 0], N(radius))
C3 = minkowski_difference(P3, Q3)
C3_res = HPolyhedron(N[mx1 0; 0 mx2], N[3 - mx1*radius, 3 - mx2*radius])
@test C3 C3_res && C3_res C3

# concrete Reflection
F4 = N[3 0; 0 7]
g4 = N[1, 2]
Expand Down

0 comments on commit 6d946ad

Please sign in to comment.