Polygons (AbstractPolygon)
A polygon is a two-dimensional polytope.
LazySets.AbstractPolygon
— TypeAbstractPolygon{N} <: AbstractPolytope{N}
Abstract type for convex polygons (i.e., two-dimensional polytopes).
Notes
The subtypes of AbstractPolygon
(including abstract interfaces):
julia> subtypes(AbstractPolygon)
2-element Vector{Any}:
AbstractHPolygon
VPolygon
This interface defines the following functions (undocumented):
Inherited from LazySet
:
area
center
chebyshev_center_radius
complement
concretize
constraints
convex_hull
copy(::Type{LazySet})
delaunay
diameter
eltype
eltype
isoperation
norm
polyhedron
radius
rationalize
rectify
reflect
singleton_list
surface
tosimplehrep
triangulate
vertices
affine_map
exponential_map
is_interior_point
linear_map
sample
scale
ρ
translate
cartesian_product
convex_hull
exact_sum
≈
==
isequivalent
⊂
minkowski_difference
Inherited from ConvexSet
:
Inherited from AbstractPolyhedron
:
Inherited from AbstractPolytope
:
The following helper functions are used for sorting directions:
LazySets.jump2pi
— Functionjump2pi(x::N) where {N<:AbstractFloat}
Return $x + 2π$ if $x$ is negative, otherwise return $x$.
Input
x
– real scalar
Output
$x + 2π$ if $x$ is negative, $x$ otherwise.
Examples
julia> using LazySets: jump2pi
julia> jump2pi(0.0)
0.0
julia> jump2pi(-0.5)
5.783185307179586
julia> jump2pi(0.5)
0.5
LazySets.:⪯
— Method⪯(u::AbstractVector, v::AbstractVector)
Compare two 2D vectors by their direction.
Input
u
– first 2D directionv
– second 2D direction
Output
true
iff $\arg(u) [2π] ≤ \arg(v) [2π]$.
Notes
The argument is measured in counter-clockwise fashion, with the 0 being the direction (1, 0).
Algorithm
The implementation checks the quadrant of each direction, and compares directions using the right-hand rule. In particular, this method does not use the arctangent.
LazySets._leq_trig
— Method_leq_trig(u::AbstractVector{N}, v::AbstractVector{N}) where {N<:AbstractFloat}
Compare two 2D vectors by their direction.
Input
u
– first 2D directionv
– second 2D direction
Output
true
iff $\arg(u) [2π] ≤ \arg(v) [2π]$.
Notes
The argument is measured in counter-clockwise fashion, with the 0 being the direction (1, 0).
Algorithm
The implementation uses the arctangent function with sign, atan
, which for two arguments implements the atan2
function.
LazySets.quadrant
— Methodquadrant(w::AbstractVector)
Compute the quadrant where the direction w
belongs.
Input
w
– direction
Output
An integer from 0 to 3, with the following convention:
^
1 | 0
---+-->
2 | 3
Algorithm
The idea is to encode the following logic function: $11 ↦ 0, 01 ↦ 1, 00 ↦ 2, 10 ↦ 3$, according to the convention above.
This function is inspired from AGPX's answer in: Sort points in clockwise order?