Line

LazySets.LineModule.LineType
Line{N, VN<:AbstractVector{N}} <: AbstractPolyhedron{N}

Type that represents a line of the form

\[ \{y ∈ ℝ^n: y = p + λd, λ ∈ ℝ\}\]

where $p$ is a point on the line and $d$ is its direction vector (not necessarily normalized).

Fields

  • p – point on the line
  • d – direction

Examples

There are three constructors. The optional keyword argument normalize (default: false) can be used to normalize the direction of the resulting line to have norm 1 (w.r.t. the Euclidean norm).

  1. The default constructor takes the fields p and d:

The line passing through the point $[-1, 2, 3]$ and parallel to the vector $[3, 0, -1]$:

julia> Line([-1.0, 2, 3], [3.0, 0, -1])
Line{Float64, Vector{Float64}}([-1.0, 2.0, 3.0], [3.0, 0.0, -1.0])

julia> Line([-1.0, 2, 3], [3.0, 0, -1]; normalize=true)
Line{Float64, Vector{Float64}}([-1.0, 2.0, 3.0], [0.9486832980505138, 0.0, -0.31622776601683794])
  1. The second constructor takes two points, from and to, as keyword

arguments, and returns the line through them. See the algorithm section for details.

julia> Line(from=[-1.0, 2, 3], to=[-4.0, 2, 4])
Line{Float64, Vector{Float64}}([-1.0, 2.0, 3.0], [3.0, 0.0, -1.0])
  1. The third constructor resembles Line2D and only works for two-dimensional

lines. It takes two inputs, a and b, and constructs the line such that $a ⋅ x = b$.

julia> Line([2.0, 0], 1.)
Line{Float64, Vector{Float64}}([0.5, 0.0], [0.0, -1.0])

Algorithm

Given two points $p ∈ ℝ^n$ and $q ∈ ℝ^n$, the line that passes through these two points is L:{y ∈ ℝ^n: y = p + λ(q - p), λ ∈ ℝ}``.

source

Operations

LazySets.API.constraints_listMethod
constraints_list(L::Line)

Return the list of constraints of a line.

Input

  • L – line

Output

A list containing 2n-2 half-spaces whose intersection is L, where n is the ambient dimension of L.

source
LazySets.API.dimMethod
dim(L::Line)

Return the ambient dimension of a line.

Input

  • L – line

Output

The ambient dimension of the line.

source
Base.isemptyMethod
isempty(L::Line)

Check whether a line is empty.

Input

  • L – line

Output

false.

source
LazySets.API.isuniversalMethod
isuniversal(L::Line; [witness::Bool]=false)

Check whether a line is universal.

Input

  • P – line
  • witness – (optional, default: false) compute a witness if activated

Output

  • If witness is false: true if the ambient dimension is one, false

otherwise.

  • If witness is true: (true, []) if the ambient dimension is one,

(false, v) where $v ∉ P$ otherwise.

source
LinearAlgebra.normalizeMethod
normalize(L::Line{N}, p::Real=N(2)) where {N}

Normalize the direction of a line.

Input

  • L – line
  • p – (optional, default: 2.0) vector p-norm used in the normalization

Output

A line whose direction has unit norm w.r.t. the given p-norm.

Notes

See also normalize!(::Line, ::Real) for the in-place version.

source
LinearAlgebra.normalize!Method
normalize!(L::Line{N}, p::Real=N(2)) where {N}

Normalize the direction of a line storing the result in L.

Input

  • L – line
  • p – (optional, default: 2.0) vector p-norm used in the normalization

Output

A line whose direction has unit norm w.r.t. the given p-norm.

source
Base.randMethod
rand(::Type{Line}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
     [rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing)

Create a random line.

Input

  • Line – type for dispatch
  • N – (optional, default: Float64) numeric type
  • dim – (optional, default: 2) dimension
  • rng – (optional, default: GLOBAL_RNG) random number generator
  • seed – (optional, default: nothing) seed for reseeding

Output

A random line.

Algorithm

All numbers are normally distributed with mean 0 and standard deviation 1.

source
ReachabilityBase.Arrays.distanceMethod
distance(x::AbstractVector, L::Line; [p]::Real=2.0)

Compute the distance between point x and the line with respect to the given p-norm.

Input

  • x – point/vector
  • L – line
  • p – (optional, default: 2.0) the p-norm used; p = 2.0 corresponds to the usual Euclidean norm

Output

A scalar representing the distance between x and the line L.

source
Base.:∈Method
∈(x::AbstractVector, L::Line)

Check whether a given point is contained in a line.

Input

  • x – point/vector
  • L – line

Output

true iff x ∈ L.

Algorithm

The point $x$ belongs to the line $L : p + λd$ if and only if $x - p$ is proportional to the direction $d$.

source
LazySets.API.linear_mapMethod
linear_map(M::AbstractMatrix, L::Line)

Concrete linear map of a line.

Input

  • M – matrix
  • L – line

Output

The line obtained by applying the linear map, if that still results in a line, or a Singleton otherwise.

Algorithm

We apply the linear map to the point and direction of L. If the resulting direction is zero, the result is a singleton.

source
LazySets.API.ρMethod
ρ(d::AbstractVector, L::Line)

Evaluate the support function of a line in a given direction.

Input

  • d – direction
  • L – line

Output

Evaluation of the support function in the given direction.

source
LazySets.API.σMethod
σ(d::AbstractVector, L::Line)

Return a support vector of a line in a given direction.

Input

  • d – direction
  • L – line

Output

A support vector in the given direction.

source
LazySets.API.translate!Method
translate!(L::Line, v::AbstractVector)

Translate (i.e., shift) a line by a given vector, in-place.

Input

  • L – line
  • v – translation vector

Output

The line L translated by v.

source

Inherited from LazySet: