Skip to content

Commit

Permalink
simplification + some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Nov 8, 2018
1 parent ca589b2 commit ac55f2e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/concrete_intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,38 @@ one.
function intersection(P1::AbstractHPolygon{N},
P2::AbstractHPolygon{N}
)::Union{HPolygon{N}, EmptySet{N}} where N<:Real
# all constraints of one polygon are processed; now add the other polygon's
# constraints
@inline function add_remaining_constraints!(c, i, c1, i1, duplicates)
c[i+1:length(c)-duplicates] = c1[i1:length(c1)]
return true
end

# choose the constraint of c1; the directions are different
@inline function choose_first_diff_dir!(c, i, i1, i2, c1, c2, duplicates)
c[i] = c1[i1]
if i1 == length(c1)
c[i+1:length(c)-duplicates] = c2[i2:length(c2)]
return true
return add_remaining_constraints!(c, i, c2, i2, duplicates)
end
return false
end

# choose the constraint of c1; the directions are equivalent (i.e., linearly
# dependent)
@inline function choose_first_same_dir!(c, i, i1, i2, c1, c2, duplicates)
c[i] = c1[i1]
if i1 == length(c1)
if i2 < length(c2)
c[i+1:length(c)-duplicates] = c2[i2+1:length(c2)]
return add_remaining_constraints!(c, i, c2, i2+1, duplicates)
end
return true
elseif i2 == length(c2)
c[i+1:length(c)-duplicates] = c1[i1+1:length(c1)]
return true
return add_remaining_constraints!(c, i, c1, i1+1, duplicates)
end
return false
end

# check if the first of two constraint with equivalent direction is tighter
@inline function is_first_constraint_tighter(lc1::LinearConstraint{N},
lc2::LinearConstraint{N}
) where {N<:Real}
Expand Down

0 comments on commit ac55f2e

Please sign in to comment.