46 template <
class Distribution,
class Generator>
84 template <
class... Args>
117 template <
class RealType>
134 template <
class Iterator,
class Generator>
136 operator()(
const Iterator& first,
const Iterator& last, Generator& gen)
140 for (
auto it = first; it != last; ++it)
143 length += std::pow(*it, 2.0);
146 length = std::sqrt(length);
148 for (
auto it = first; it != last; ++it)
166 template <
class RealType>
186 template <
class Iterator,
class Generator>
188 operator()(
const Iterator& first,
const Iterator& last, Generator& gen)
190 const RealType dim = std::distance(first, last);
193 for (
auto it = first; it != last; ++it)
196 length += std::pow(*it, 2.0);
199 length = std::sqrt(length);
200 const auto scalingFactor = std::pow(
radDist(gen), 1.0 / dim);
202 for (
auto it = first; it != last; ++it)
204 *it = ((*it) / length) * scalingFactor;
216 std::uniform_real_distribution<RealType>
radDist;
222 template <
class RealType>
237 template <
class Iterator>
242 for (; boundsFirst != boundsLast; ++boundsFirst)
245 volume *= (boundsFirst->second - boundsFirst->first);
250 std::nextafter(boundsFirst->second, std::numeric_limits<RealType>::max()));
260 template <
class Iterator,
class Generator>
264 for (std::size_t i = 0; i <
spaceDist.size(); ++i, ++first)
276 template <
class Iterator>
280 for (std::size_t i = 0; i <
spaceDist.size(); ++i, ++first)
305 template <
class T = std::
size_t>
320 std::vector<std::uniform_real_distribution<RealType>>
spaceDist;
328 template <
class RealType =
float>
350 template <
class ValIter>
353 ValIter focalBFirst) :
377 template <
class ValIter>
381 const std::vector<RealType>& rotationMatrix) :
398 rotation = Eigen::Map<const MatType>(
407 template <
class Generator>
422 template <
class T = std::
size_t>
426 return static_cast<T>(
tmpVal.size());
482 tmpVec(0) = newPolarDiameter / 2.0;
484 const auto polarDiameterQuad = std::pow(newPolarDiameter, 2.0);
486 const auto equatorialRadius =
487 std::sqrt(polarDiameterQuad - distanceFocalPointsQuad) / 2.0;
491 tmpVec(i) = equatorialRadius;
505 std::vector<RealType>
520 template <
class IteratorType>
523 IteratorType focalBFirst,
524 bool updateRotationMatrix =
true)
530 for (std::size_t i = 0; i <
getDimensionality(); ++i, ++focalAFirst, ++focalBFirst)
539 tmpVec(i) = focalPointsDelta;
545 if (updateRotationMatrix)
581 Eigen::JacobiSVD<MatType, Eigen::NoQRPreconditioner> jacoby(
583 (normalizedFocalPointAToB * (MatType::Identity(n, n).col(0).
transpose())),
584 Eigen::ComputeFullV |
589 VecType diag = VecType::Ones(n);
591 diag(n - 1) = jacoby.matrixU().determinant() * jacoby.matrixV().determinant();
594 rotation = jacoby.matrixU() * diag.asDiagonal() * jacoby.matrixV().transpose();
649 template <
class RealType =
float>
665 template <
class ValIter,
class BoundsIter>
667 BoundsIter boundsLast,
671 const std::vector<RealType>& rotationMatrix) :
674 cMax{
std::numeric_limits<RealType>::infinity()}
678 throw std::logic_error{
"differend bounds for spheroid and cuboid"};
692 template <
class ValIter,
class BoundsIter>
694 BoundsIter boundsLast,
697 ValIter focalBFirst) :
700 cMax{
std::numeric_limits<RealType>::infinity()}
704 throw std::logic_error{
"differend bounds for spheroid and cuboid"};
713 template <
class Generator>
717 if (
cMax < std::numeric_limits<RealType>::infinity())
787 template <
class T = std::
size_t>
Stores a distribution and a generator.
Generator GeneratorType
Type of the stored generator.
Generator & getGenerator()
Returns the stored generator.
Distribution & getDistribution()
Returns the stored distribution.
Sampler(Distribution &&dist, Generator &&gen)
Ctor.
Distribution DistributionType
Type of the stored distribution.
auto operator()(Args &&... args) -> decltype(distribution(std::forward< Args >(args)..., generator))
Passes all arguments followed by the generator to the distribution.
UniformCuboidDistribution< float > distribution
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
This file offers overloads of toIce() and fromIce() functions for STL container types.
Sampler< UniformInformedProlateSpheroidDistribution< float >, std::mt19937 > InformedSampler
Typedef for a sampler as required by informed rrt*.
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T > > &src, Thrower thrower)
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Sampler< UniformCuboidDistribution< float >, std::mt19937 > CuboidSampler
RealType volumeOfHyperspheroid(std::size_t n, RealType polarRadius, RealType equatorialRadius)
Returns the volume of a hyperspheroid with given dimensionality and radii.
double norm(const Point &a)
double distance(const Point &a, const Point &b)