23 template <
typename DataPo
int>
25 const typename DataPoint::VectorType
_vCenter,
29 using Scalar =
typename DataPoint::Scalar;
30 using VectorType =
typename DataPoint::VectorType;
32 VectorType
vNormal = VectorType::Random().normalized();
38 Eigen::internal::random<Scalar>(Scalar(0.), Scalar(1. - MIN_NOISE));
45 Eigen::internal::random<Scalar>(Scalar(0.), Scalar(1. - MIN_NOISE));
50 const float reverse = Eigen::internal::random<float>(0.f, 1.f);
59 template <
typename VectorType>
62 using Scalar =
typename VectorType::Scalar;
64 const Scalar
theta = Eigen::internal::random<Scalar>(0, Scalar(2. *
EIGEN_PI));
67 const Scalar
r =
_radius * std::sqrt(Eigen::internal::random<Scalar>(0, 1));
78 template <
typename DataPo
int>
80 const typename DataPoint::VectorType& ,
81 const typename DataPoint::Scalar&
_width,
82 const typename DataPoint::Scalar&
_height,
87 using Scalar =
typename DataPoint::Scalar;
88 using VectorType =
typename DataPoint::VectorType;
90 const Scalar
u = Eigen::internal::random<Scalar>(-
_width / Scalar(2),
_width / Scalar(2));
91 const Scalar
v = Eigen::internal::random<Scalar>(-
_height / Scalar(2),
_height / Scalar(2));
98 VectorType::Random().normalized() * Eigen::internal::random<Scalar>(0., 1. - MIN_NOISE);
105 template <
typename DataPo
int>
107 const typename DataPoint::VectorType
_vNormal,
108 const typename DataPoint::Scalar
_radius,
112 using Scalar =
typename DataPoint::Scalar;
113 using VectorType =
typename DataPoint::VectorType;
123 vRandom = VectorType::Random().normalized();
134 Eigen::internal::random<Scalar>(Scalar(0), Scalar(1. - MIN_NOISE));
142 Scalar
rotationAngle = Eigen::internal::random<Scalar>(Scalar(-M_PI / 16.), Scalar(M_PI / 16.));
148 rotationAngle = Eigen::internal::random<Scalar>(Scalar(-M_PI / 16.), Scalar(M_PI / 16.));
157 const float reverse = Eigen::internal::random<float>(0.f, 1.f);
168 template <
typename Scalar>
175 template <
typename Scalar>
177 Scalar
_e, Scalar
_f)
183 template <
typename VectorType>
185 const typename VectorType::Scalar
_b)
187 return VectorType((
_a *
in.x()), (
_b *
in.y()), -1.).normalized();
190 template <
typename DataPo
int>
191 inline typename std::enable_if<Ponca::hasNormal<DataPoint>::value,
void>::type
getParaboloidNormal(
192 DataPoint&
in,
typename DataPoint::Scalar
_a,
typename DataPoint::Scalar
_b,
typename DataPoint::Scalar
_c,
193 typename DataPoint::Scalar
_d,
typename DataPoint::Scalar
_e,
typename DataPoint::Scalar
_f)
195 static constexpr typename DataPoint::Scalar
two{2};
196 auto& pos = in.pos();
197 in.normal() =
typename DataPoint::VectorType(two * _a * pos.x() + _c * pos.y() + _d,
198 two * _b * pos.y() + _c * pos.x() + _d, -1.)
202 template <
typename DataPo
int>
203 inline typename std::enable_if<!Ponca::hasNormal<DataPoint>::value,
void>::type
getParaboloidNormal(
204 DataPoint& in,
typename DataPoint::Scalar _a,
typename DataPoint::Scalar _b,
typename DataPoint::Scalar _c,
205 typename DataPoint::Scalar _d,
typename DataPoint::Scalar _e,
typename DataPoint::Scalar _f)
214 template <
typename DataPo
int>
216 const typename DataPoint::Scalar
_b,
217 const typename DataPoint::Scalar
_s,
const bool _bAddNoise =
true)
219 using Scalar =
typename DataPoint::Scalar;
220 using VectorType =
typename DataPoint::VectorType;
225 const Scalar x = Eigen::internal::random<Scalar>(-
_s,
_s),
y = Eigen::internal::random<Scalar>(-
_s,
_s);
232 VectorType::Random().normalized() * Eigen::internal::random<Scalar>(Scalar(0), Scalar(1. - MIN_NOISE));
240 template <
typename DataPo
int>
242 typename DataPoint::Scalar
_c,
typename DataPoint::Scalar
_d,
243 typename DataPoint::Scalar
_e,
typename DataPoint::Scalar
_f,
246 using Scalar =
typename DataPoint::Scalar;
247 using VectorType =
typename DataPoint::VectorType;
261 VectorType::Random().normalized() * Eigen::internal::random<Scalar>(Scalar(0), Scalar(1. - MIN_NOISE));
267 template <
typename DataPo
int,
typename Params>
268 [[nodiscard]] DataPoint
getPointOnParaboloid(
const Params& _params,
typename DataPoint::Scalar _s,
269 bool _bAddNoise =
true)
271 return getPointOnParaboloid<DataPoint>(_params(0), _params(1), _params(2), _params(3), _params(4), _params(5),
276 template <
typename DataPo
int>
279 using Scalar =
typename DataPoint::Scalar;
280 using VectorType =
typename DataPoint::VectorType;
281 const VectorType n = VectorType::Random().normalized();
282 const VectorType
p = n * Eigen::internal::random<Scalar>(MIN_NOISE, MAX_NOISE);
283 return {
p, (n + VectorType::Random() * Scalar(0.1)).
normalized()};
Aggregator class used to declare specialized structures using CRTP.
VectorType getParaboloidNormal(const VectorType &in, const typename VectorType::Scalar _a, const typename VectorType::Scalar _b)
Generate z value using the equation z = ax^2 + by^2.
Scalar getParaboloidZ(const Scalar _x, const Scalar _y, const Scalar _a, const Scalar _b)
Generate z value using the equation z = ax^2 + by^2.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
DataPoint getPointOnPlane(const typename DataPoint::VectorType _vPosition, const typename DataPoint::VectorType _vNormal, const typename DataPoint::Scalar _radius, const bool _bAddPositionNoise=true, const bool _bAddNormalNoise=true, const bool _bReverseNormals=false)
Generate points on a plane.
DataPoint getPointOnParaboloid(const typename DataPoint::Scalar _a, const typename DataPoint::Scalar _b, const typename DataPoint::Scalar _s, const bool _bAddNoise=true)
Generate point samples on the primitive z = ax^2 + by^2.
DataPoint getRandomPoint()
Generate a random points.
DataPoint getPointOnSphere(const typename DataPoint::Scalar _radius, const typename DataPoint::VectorType _vCenter, const bool _bAddPositionNoise=true, const bool _bAddNormalNoise=true, const bool _bReverseNormals=false)
Generate points on a sphere.
DataPoint getPointOnRectangularPlane(const typename DataPoint::VectorType &_vPosition, const typename DataPoint::VectorType &, const typename DataPoint::Scalar &_width, const typename DataPoint::Scalar &_height, const typename DataPoint::VectorType &_localxAxis, const typename DataPoint::VectorType &_localyAxis, const bool _bAddPositionNoise=true)
Generate points on a plane without normals.
VectorType getPointOnCircle(typename VectorType::Scalar _radius, VectorType _vCenter)
Sample points on a circle in the xy plane.