Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 126 additions & 13 deletions docs/src/lib/sets/Line2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,148 @@ Line2D

## Operations

```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
an_element(::LazySet)
```
```@meta
CurrentModule = LazySets.Line2DModule
```
```@docs
an_element(::Line2D)
constrained_dimensions(::Line2D)
constraints_list(::Line2D)
dim(::Line2D)
isbounded(::Line2D)
isempty(::Line2D)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
isuniversal(::LazySet, ::Bool=false)
```
```@meta
CurrentModule = LazySets.Line2DModule
```
```@docs
isuniversal(::Line2D, ::Bool=false)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
rand(::Type{LazySet})
```
```@meta
CurrentModule = LazySets.Line2DModule
```
```@docs
rand(::Type{Line2D})
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
∈(::AbstractVector, ::LazySet)
```
```@meta
CurrentModule = LazySets.Line2DModule
```
```@docs
∈(::AbstractVector, ::Line2D)
project(::AbstractVector, ::Line2D)
σ(::AbstractVector, ::Line2D)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
translate(::LazySet, ::AbstractVector)
```
```@meta
CurrentModule = LazySets.Line2DModule
```
```@docs
translate(::Line2D, ::AbstractVector)
```
```@meta
CurrentModule = LazySets.API
```
```@docs; canonical=false
intersection(::LazySet, ::LazySet)
```
```@meta
CurrentModule = LazySets.Line2DModule
```
```@docs
intersection(::Line2D, ::Line2D)
```

```@meta
CurrentModule = LazySets.API
```

Undocumented implementations:
* [`constraints_list`](@ref constraints_list(::LazySet))
* [`dim`](@ref dim(::LazySet))
* [`isbounded`](@ref isbounded(::LazySet))
* [`isempty`](@ref isempty(::LazySet))
* [`isoperationtype`](@ref isoperationtype(::Type{LazySet}))
* [`project`](@ref project(::LazySet, ::AbstractVector{Int}))
* [`σ`](@ref σ(::AbstractVector, ::LazySet))
* [`isdisjoint`](@ref isdisjoint(::LazySet, ::LazySet))

```@meta
CurrentModule = LazySets
```

Inherited from [`LazySet`](@ref):
* [`diameter`](@ref diameter(::LazySet, ::Real))
* [`high`](@ref high(::LazySet))
* [`high`](@ref high(::LazySet, ::Int))
* [`low`](@ref low(::LazySet))
* [`low`](@ref low(::LazySet, ::Int))
* [`norm`](@ref norm(::LazySet, ::Real))
* [`radius`](@ref radius(::LazySet, ::Real))
* [`area`](@ref area(::LazySet))
* [`complement`](@ref complement(::LazySet))
* [`concretize`](@ref concretize(::LazySet))
* [`constraints`](@ref constraints(::LazySet))
* [`convex_hull`](@ref convex_hull(::LazySet))
* `copy(::Type{LazySet})`
* [`diameter`](@ref diameter(::LazySet, ::Real=Inf))
* [`eltype`](@ref eltype(::Type{<:LazySet}))
* [`eltype`](@ref eltype(::LazySet))
* [`isboundedtype`](@ref isboundedtype(::Type{LazySet}))
* [`isoperation`](@ref isoperation(::LazySet))
* [`norm`](@ref norm(::LazySet, ::Real=Inf))
* [`radius`](@ref radius(::LazySet, ::Real=Inf))
* [`rectify`](@ref rectify(::LazySet))
* [`reflect`](@ref reflect(::LazySet))
* [`singleton_list`](@ref singleton_list(::LazySet))
* [`surface`](@ref surface(::LazySet))
* [`vertices`](@ref vertices(::LazySet))
* [`volume`](@ref volume(::LazySet))
* [`affine_map`](@ref affine_map(::AbstractMatrix, ::LazySet, ::AbstractVector))
* [`exponential_map`](@ref exponential_map(::AbstractMatrix, ::LazySet))
* [`is_interior_point`](@ref is_interior_point(::AbstractVector, ::LazySet))
* [`linear_map`](@ref linear_map(::AbstractMatrix, ::LazySet))
* [`sample`](@ref sample(::LazySet, ::Int=1))
* [`scale`](@ref scale(::Real, ::LazySet))
* [`ρ`](@ref ρ(::AbstractVector, ::LazySet))
* [`translate!`](@ref translate!(::LazySet, ::AbstractVector))
* [`cartesian_product`](@ref cartesian_product(::LazySet, ::LazySet))
* [`convex_hull`](@ref convex_hull(::LazySet, ::LazySet))
* [`exact_sum`](@ref exact_sum(::LazySet, ::LazySet))
* [`≈`](@ref ≈(::LazySet, ::LazySet))
* [`==`](@ref ==(::LazySet, ::LazySet))
* [`isequivalent`](@ref isequivalent(::LazySet, ::LazySet))
* [`⊂`](@ref ⊂(::LazySet, ::LazySet))
* [`minkowski_difference`](@ref minkowski_difference(::LazySet, ::LazySet))

Inherited from [`ConvexSet`](@ref):
* [`linear_combination`](@ref linear_combination(::ConvexSet, ::ConvexSet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`linear_map`](@ref linear_map(::AbstractMatrix, ::AbstractPolyhedron))
* [`extrema`](@ref extrema(::AbstractPolyhedron))
* [`extrema`](@ref extrema(::AbstractPolyhedron, ::Int))
* [`high`](@ref high(::AbstractPolyhedron))
* [`high`](@ref high(::AbstractPolyhedron, ::Int))
* [`isconvextype`](@ref isconvextype(::Type{AbstractPolyhedron}))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))
* [`low`](@ref low(::AbstractPolyhedron))
* [`low`](@ref low(::AbstractPolyhedron, ::Int))
* [`vertices_list`](@ref vertices_list(::AbstractPolyhedron))
* [`⊆`](@ref ⊆(::LazySet, ::AbstractPolyhedron))
* [`minkowski_sum`](@ref minkowski_sum(::AbstractPolyhedron, ::AbstractPolyhedron))
34 changes: 0 additions & 34 deletions src/ConcreteOperations/isdisjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -966,40 +966,6 @@ for ST in [:AbstractPolyhedron, :AbstractSingleton, :HalfSpace, :Hyperplane,
end
end

"""
isdisjoint(L1::Line2D, L2::Line2D, [witness]::Bool=false)

Check whether two two-dimensional lines do not intersect, and otherwise
optionally compute a witness.

### Input

- `L1` -- two-dimensional line
- `L2` -- two-dimensional line
- `witness` -- (optional, default: `false`) compute a witness if activated

### Output

* If `witness` option is deactivated: `true` iff ``L1 ∩ L2 = ∅``
* If `witness` option is activated:
* `(true, [])` iff ``L1 ∩ L2 = ∅``
* `(false, v)` iff ``L1 ∩ L2 ≠ ∅`` and ``v ∈ L1 ∩ L2``
"""
function isdisjoint(L1::Line2D, L2::Line2D, witness::Bool=false)
disjoint = _isdisjoint(L1, L2)
if disjoint
return _witness_result_empty(witness, true, L1, L2)
end
return witness ? (false, an_element(intersection(L1, L2))) : false
end

# the lines do not intersect <=> det is zero and they are not identical
function _isdisjoint(L1::Line2D, L2::Line2D)
det = right_turn(L1.a, L2.a)
disjoint = isapproxzero(det) && !isapprox(L1.b, L2.b)
return disjoint
end

for ST in [:AbstractZonotope, :AbstractSingleton]
@eval @commutative function isdisjoint(C::CartesianProduct{N,<:LazySet,<:Universe},
Z::$(ST)) where {N}
Expand Down
9 changes: 5 additions & 4 deletions src/Sets/Line2D/Line2DModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ using Reexport, Requires
using ..LazySets: AbstractPolyhedron, AbstractLinearMapAlgorithm,
_constraints_list_hyperplane, _intersection_line2d,
_linear_map_hrep, _non_element_halfspace,
_σ_hyperplane_halfspace
_σ_hyperplane_halfspace, _witness_result_empty
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: nonzero_indices
using ReachabilityBase.Arrays: nonzero_indices, right_turn
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Comparison: _isapprox
using ReachabilityBase.Comparison: isapproxzero, _isapprox
using ReachabilityBase.Require: require

@reexport import ..API: an_element, constraints_list, dim, isbounded, isempty,
isoperationtype, isuniversal, rand, ∈, project, σ,
translate, intersection
translate, intersection, isdisjoint
@reexport import ..LazySets: constrained_dimensions
import ..LazySets: _linear_map_hrep_helper
@reexport using ..API
Expand All @@ -38,6 +38,7 @@ include("project.jl")
include("support_vector.jl")
include("translate.jl")
include("intersection.jl")
include("isdisjoint.jl")

include("constrained_dimensions.jl")

Expand Down
12 changes: 2 additions & 10 deletions src/Sets/Line2D/an_element.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
"""
an_element(L::Line2D)

Return some element of a 2D line.

### Input
# Extended help

- `L` -- 2D line

### Output

An element on the line.
an_element(L::Line2D)

### Algorithm

Expand Down
13 changes: 0 additions & 13 deletions src/Sets/Line2D/constraints_list.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
constraints_list(L::Line2D)

Return the list of constraints of a 2D line.

### Input

- `L` -- 2D line

### Output

A list containing two half-spaces.
"""
function constraints_list(L::Line2D)
return _constraints_list_hyperplane(L.a, L.b)
end
15 changes: 1 addition & 14 deletions src/Sets/Line2D/dim.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
dim(L::Line2D)

Return the ambient dimension of a 2D line.

### Input

- `L` -- 2D line

### Output

The ambient dimension of the line, which is 2.
"""
function dim(L::Line2D)
function dim(::Line2D)
return 2
end
13 changes: 2 additions & 11 deletions src/Sets/Line2D/in.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
"""
∈(x::AbstractVector, L::Line2D)

Check whether a given point is contained in a 2D line.

### Input
# Extended help

- `x` -- point/vector
- `L` -- 2D line

### Output

`true` iff `x ∈ L`.
∈(x::AbstractVector, L::Line2D)

### Algorithm

Expand Down
9 changes: 2 additions & 7 deletions src/Sets/Line2D/intersection.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"""
intersection(L1::Line2D, L2::Line2D)

Compute the intersection of two two-dimensional lines.
# Extended help

### Input

- `L1` -- line
- `L2` -- line
intersection(L1::Line2D, L2::Line2D)

### Output

Expand Down
13 changes: 0 additions & 13 deletions src/Sets/Line2D/isbounded.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
isbounded(L::Line2D)

Check whether a 2D line is bounded.

### Input

- `L` -- 2D line

### Output

`false`.
"""
function isbounded(::Line2D)
return false
end
14 changes: 14 additions & 0 deletions src/Sets/Line2D/isdisjoint.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function isdisjoint(L1::Line2D, L2::Line2D, witness::Bool=false)
disjoint = _isdisjoint(L1, L2)
if disjoint
return _witness_result_empty(witness, true, L1, L2)
end
return witness ? (false, an_element(intersection(L1, L2))) : false
end

# the lines do not intersect <=> det is zero and they are not identical
function _isdisjoint(L1::Line2D, L2::Line2D)
det = right_turn(L1.a, L2.a)
disjoint = isapproxzero(det) && !isapprox(L1.b, L2.b)
return disjoint
end
15 changes: 1 addition & 14 deletions src/Sets/Line2D/isempty.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
isempty(L::Line2D)

Check whether a 2D line is empty.

### Input

- `L` -- 2D line

### Output

`false`.
"""
function isempty(L::Line2D)
function isempty(::Line2D)
return false
end
14 changes: 2 additions & 12 deletions src/Sets/Line2D/isuniversal.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
"""
isuniversal(L::Line2D, [witness]::Bool=false)

Check whether a 2D line is universal.

### Input
# Extended help

- `L` -- 2D line
- `witness` -- (optional, default: `false`) compute a witness if activated

### Output

* If `witness` option is deactivated: `false`
* If `witness` option is activated: `(false, v)` where ``v ∉ L``
isuniversal(L::Line2D, [witness]::Bool=false)

### Algorithm

Expand Down
Loading
Loading