Go to the documentation of this file.
28 #include <type_traits>
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);
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)
193 for (
auto it = first; it != last; ++it)
196 length += std::pow(*it, 2.0);
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);
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>
412 Eigen::Map<VecType> tmpVec{
tmpVal.data(), getDimensionality<long int>()};
422 template <
class T = std::
size_t>
426 return static_cast<T>(
tmpVal.size());
481 Eigen::Map<VecType> tmpVec{
tmpVal.data(), getDimensionality<long int>()};
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)
526 Eigen::Map<VecType> tmpVec{
tmpVal.data(), getDimensionality<long int>()};
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(
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>
Distribution & getDistribution()
Returns the stored distribution.
auto operator()(Args &&... args) -> decltype(distribution(std::forward< Args >(args)..., generator))
Passes all arguments followed by the generator to the distribution.
Sampler(Distribution &&dist, Generator &&gen)
Ctor.
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Stores a distribution and a generator.
Generator generator
The stored generator.
void Identity(MatrixXX< N, N, T > *a)
Generator & getGenerator()
Returns the stored generator.
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the including the above license this restriction and the following must be included in all copies of the in whole or in and all derivative works of the unless such copies or derivative works are solely in the form of machine executable object code generated by a source language processor THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR TITLE AND NON INFRINGEMENT IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN TORT OR ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE The MIT Marcin Kalicinski Permission is hereby free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Distribution DistributionType
Type of the stored distribution.
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Distribution distribution
The stored distribution.
double distance(const Point &a, const Point &b)
Generator GeneratorType
Type of the stored generator.
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T >> &src, Thrower thrower)
This file offers overloads of toIce() and fromIce() functions for STL container types.
double norm(const Point &a)