Hyperrectangle
LazySets.Hyperrectangle
— Type.Hyperrectangle{N<:Real, VNC<:AbstractVector{N}, VNR<:AbstractVector{N}
} <: AbstractHyperrectangle{N}
Type that represents a hyperrectangle.
A hyperrectangle is the Cartesian product of one-dimensional intervals.
Fields
center
– center of the hyperrectangle as a real vectorradius
– radius of the ball as a real vector, i.e., half of its width along each coordinate direction
Examples
The Hyperrectangle
type stores a vector representing the center and another vector representing the radius. The default constructor Hyperrectangle(c, r)
receives the center and radius, in that order. For instance,
julia> c = [-1.0, 1.0];
julia> r = [2.0, 1.0];
julia> H = Hyperrectangle(c, r)
Hyperrectangle{Float64,Array{Float64,1},Array{Float64,1}}([-1.0, 1.0], [2.0, 1.0])
Which creates the hyperrectangle with vertices:
julia> vertices_list(H)
4-element Array{Array{Float64,1},1}:
[1.0, 2.0]
[-3.0, 2.0]
[1.0, 0.0]
[-3.0, 0.0]
The getter functions for the center and the radius are center
and radius_hyperrectangle
(since radius
corresponds to the radius of the enclosing ball of minimal volume):
julia> center(H)
2-element Array{Float64,1}:
-1.0
1.0
julia> radius_hyperrectangle(H)
2-element Array{Float64,1}:
2.0
1.0
There is also a constructor from lower and upper bounds with keyword arguments high
and low
. The following construction results in the same hyperrectangle as in the previous paragraph:
julia> l = [-3.0, 0.0];
julia> h = [1.0, 2.0];
julia> Hyperrectangle(low=l, high=h)
Hyperrectangle{Float64,Array{Float64,1},Array{Float64,1}}([-1.0, 1.0], [2.0, 1.0])
Base.rand
— Method.rand(::Type{Hyperrectangle}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
[rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing)
Create a random hyperrectangle.
Input
Hyperrectangle
– type for dispatchN
– (optional, default:Float64
) numeric typedim
– (optional, default: 2) dimensionrng
– (optional, default:GLOBAL_RNG
) random number generatorseed
– (optional, default:nothing
) seed for reseeding
Output
A random hyperrectangle.
Algorithm
All numbers are normally distributed with mean 0 and standard deviation 1. Additionally, the radius is nonnegative.
LazySets.center
— Method.center(H::Hyperrectangle{N}) where {N<:Real}
Return the center of a hyperrectangle.
Input
H
– hyperrectangle
Output
The center of the hyperrectangle.
LazySets.radius_hyperrectangle
— Method.radius_hyperrectangle(H::Hyperrectangle{N}) where {N<:Real}
Return the box radius of a hyperrectangle in every dimension.
Input
H
– hyperrectangle
Output
The box radius of the hyperrectangle.
LazySets.radius_hyperrectangle
— Method.radius_hyperrectangle(H::Hyperrectangle{N}, i::Int) where {N<:Real}
Return the box radius of a hyperrectangle in a given dimension.
Input
H
– hyperrectanglei
– dimension of interest
Output
The radius in the given dimension.
LazySets.translate
— Method.translate(H::Hyperrectangle{N}, v::AbstractVector{N}; share::Bool=false
) where {N<:Real}
Translate (i.e., shift) a hyperrectangle by a given vector.
Input
H
– hyperrectanglev
– translation vectorshare
– (optional, default:false
) flag for sharing unmodified parts of the original set representation
Output
A translated hyperrectangle.
Notes
The radius vector is shared with the original hyperrectangle if share == true
.
Algorithm
We add the vector to the center of the hyperrectangle.
Inherited from LazySet
:
Inherited from AbstractPolytope
:
Inherited from AbstractCentrallySymmetricPolytope
:
Inherited from AbstractZonotope
:
Inherited from AbstractHyperrectangle
: