Lodestar
An integrated real-time control package in C++
|
|
5 #ifndef LODESTAR_SINGLETON_HPP
6 #define LODESTAR_SINGLETON_HPP
10 #include "Lodestar/aux/CompileTimeQualifiers.hpp"
12 #include "SetExpression.hpp"
13 #include "SetUnion.hpp"
14 #include "EmptySet.hpp"
15 #include "SetComplement.hpp"
18 namespace primitives {
28 template<
int TDimension = -1,
typename TScalarType =
double>
31 template<
typename,
typename>
38 typedef Eigen::Matrix<TScalarType, LS_STATIC_UNLESS_DYNAMIC(TDimension), 1>
TDValue;
45 this->sEnum_ = SetEnum::Singleton;
55 template<
typename TDerived>
56 Singleton(
const Eigen::EigenBase<TDerived> &value) : value_(value)
58 this->sEnum_ = SetEnum::Singleton;
70 template<
int T_TDimension = TDimension>
72 dimension(
typename std::enable_if<(T_TDimension < 0)>::
type * =
nullptr)
const
86 template<
int T_TDimension = TDimension>
88 dimension(
typename std::enable_if<(T_TDimension >= 0)>::
type * =
nullptr)
const
103 template<
int T_TDimension = TDimension>
105 setDimension(
size_t dim,
typename std::enable_if<(T_TDimension < 0)>::
type * =
nullptr)
107 static_assert(TDimension > -1,
"Cannot set dimension of statically sized singleton.");
119 template<
int T_TDimension = TDimension>
121 setDimension(
size_t dim,
typename std::enable_if<(T_TDimension >= 0)>::
type * =
nullptr)
123 value_.conservativeResize(dim);
138 template<
typename TExpression>
139 typename std::enable_if<std::is_same<TExpression, type>::value,
bool>
::type
142 return (value_ -
static_cast<const TExpression *
>(&expr)->value_).isMuchSmallerThan(tol);
157 template<
typename TExpression>
158 typename std::enable_if<!std::is_same<TExpression, type>::value,
bool>
::type
175 template<
typename TExpression>
176 typename std::enable_if<std::is_same<TExpression, type>::value,
bool>
::type
179 return (value_ -
static_cast<const TExpression *
>(&expr)->value_).isMuchSmallerThan(1e-6);
195 template<
typename TExpression>
196 typename std::enable_if<!std::is_same<TExpression, type>::value,
bool>
::type
213 template<
typename TExpression>
214 typename std::enable_if<std::is_same<TExpression, type>::value,
bool>
::type
217 return !((value_ -
static_cast<const TExpression *
>(&expr)->value_).isMuchSmallerThan(1e-6));
231 template<
typename TExpression>
232 typename std::enable_if<!std::is_same<TExpression, type>::value,
bool>
::type
247 template<
typename TExpression>
262 template<
typename TExpression>
265 return static_cast<const TExpression *
>(&expr)->
contains(*
this);
277 template<
typename TExpression>
310 template<
typename TExpression>
326 template<
typename TDerived>
327 double sdf(Eigen::MatrixBase<TDerived> &p)
const
330 return (value_ - p).norm();
340 #endif //LODESTAR_SINGLETON_HPP
std::enable_if< std::is_same< TExpression, type >::value, bool >::type operator==(const SetExpression< TExpression > &expr) const
Checks if this expression is equal to \expr.
Definition: Singleton.hpp:176
std::enable_if< std::is_same< TExpression, type >::value, bool >::type operator!=(const SetExpression< TExpression > &expr) const
Checks if this expression is not equal to \expr.
Definition: Singleton.hpp:214
bool isSubset(const SetExpression< TExpression > &expr)
Checks if this expression is a subset of expr.
Definition: Singleton.hpp:262
Eigen::Matrix< TScalarType, LS_STATIC_UNLESS_DYNAMIC(TDimension), 1 > TDValue
Expression type.
Definition: Singleton.hpp:37
Definition: SetExpression.hpp:15
double sdf(Eigen::MatrixBase< TDerived > &p) const
Returns signed distance to p.
Definition: Singleton.hpp:326
void setDimension(size_t dim, typename std::enable_if<(T_TDimension< 0)>::type *=nullptr)
Changes the dimension of the singleton.
Definition: Singleton.hpp:104
Relative complement of two SetExpressions.
Definition: SetComplement.hpp:28
bool isSuperset(const SetExpression< TExpression > &expr)
Checks if this expression is a superset of expr.
Definition: Singleton.hpp:277
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
SetUnion< type, TExpression > unionize(const SetExpression< TExpression > &expr)
Creates a union between this expression and another SetExpression.
Definition: Singleton.hpp:247
std::enable_if< std::is_same< TExpression, type >::value, bool >::type contains(const SetExpression< TExpression > &expr, double tol=1e-6) const
Returns true if this expression contains expr.
Definition: Singleton.hpp:139
bool isEmpty() const
Returns true if the expression is the empty set.
Definition: Singleton.hpp:289
int dimension(typename std::enable_if<(T_TDimension< 0)>::type *=nullptr) const
Returns the singleton dimension.
Definition: Singleton.hpp:71
Union of two SetExpressions.
Definition: SetUnion.hpp:28
Singleton()
Value typedef.
Definition: Singleton.hpp:42
SetComplement< type, TExpression > relComplement(const SetExpression< TExpression > &expr)
Computes the relative complement of this expression and expr.
Definition: Singleton.hpp:310
A singleton set.
Definition: Singleton.hpp:29