23 const typename DataPoint::Scalar _radius,
24 const typename DataPoint::VectorType _vCenter,
25 const bool _bAddPositionNoise =
true,
26 const bool _bAddNormalNoise =
true,
27 const bool _bReverseNormals =
false
29 typedef typename DataPoint::Scalar Scalar;
30 typedef typename DataPoint::VectorType VectorType;
32 VectorType vNormal = VectorType::Random().normalized();
33 VectorType vPosition = _vCenter + vNormal * _radius;
35 if(_bAddPositionNoise)
37 vPosition = vPosition + VectorType::Random().normalized() *
38 Eigen::internal::random<Scalar>(Scalar(0.), Scalar(1. - MIN_NOISE));
39 vNormal = (vPosition - _vCenter).normalized();
44 VectorType vTempPos = vPosition + VectorType::Random().normalized() *
45 Eigen::internal::random<Scalar>(Scalar(0.), Scalar(1. - MIN_NOISE));
46 vNormal = (vTempPos - _vCenter).normalized();
50 const float reverse = Eigen::internal::random<float>(0.f, 1.f);
55 return DataPoint(vPosition, vNormal);
61 const typename DataPoint::VectorType& _vPosition,
62 const typename DataPoint::VectorType& ,
63 const typename DataPoint::Scalar& _width,
64 const typename DataPoint::Scalar& _height,
65 const typename DataPoint::VectorType& _localxAxis,
66 const typename DataPoint::VectorType& _localyAxis,
67 const bool _bAddPositionNoise =
true
69 typedef typename DataPoint::Scalar Scalar;
70 typedef typename DataPoint::VectorType VectorType;
72 const Scalar u = Eigen::internal::random<Scalar>(
73 -_width /Scalar(2), _width /Scalar(2) );
74 const Scalar v = Eigen::internal::random<Scalar>(
75 -_height/Scalar(2), _height/Scalar(2) );
77 VectorType vRandomPosition = _vPosition + u*_localxAxis + v*_localyAxis;
79 if(_bAddPositionNoise)
81 vRandomPosition = vRandomPosition +
82 VectorType::Random().normalized() *
83 Eigen::internal::random<Scalar>(0., 1. - MIN_NOISE);
86 return DataPoint(vRandomPosition);
92 const typename DataPoint::VectorType _vPosition,
93 const typename DataPoint::VectorType _vNormal,
94 const typename DataPoint::Scalar _radius,
95 const bool _bAddPositionNoise =
true,
96 const bool _bAddNormalNoise =
true,
97 const bool _bReverseNormals =
false
99 typedef typename DataPoint::Scalar Scalar;
100 typedef typename DataPoint::VectorType VectorType;
101 typedef Eigen::Quaternion<Scalar> QuaternionType;
104 VectorType vRandomDirection = VectorType::Zero();
105 VectorType vRandomPoint = VectorType::Zero();
106 VectorType vLocalUp = _vNormal;
110 vRandom = VectorType::Random().normalized();
111 vRandomDirection = vRandom.cross(vLocalUp);
113 while(vRandomDirection == VectorType::Zero());
115 vRandomDirection = vRandomDirection.normalized();
116 vRandomPoint = vRandomDirection * _radius;
117 vRandomPoint += _vPosition;
119 if(_bAddPositionNoise)
121 vRandomPoint = vRandomPoint + VectorType::Random().normalized() *
122 Eigen::internal::random<Scalar>(Scalar(0), Scalar(1. - MIN_NOISE));
127 VectorType vLocalLeft = vLocalUp.cross(vRandomDirection);
128 VectorType vLocalFront = vLocalLeft.cross(vLocalUp);
130 Scalar rotationAngle = Eigen::internal::random<Scalar>(Scalar(-M_PI / 16.), Scalar(M_PI / 16.));
131 VectorType vRotationAxis = vLocalLeft;
132 QuaternionType qRotation = QuaternionType(Eigen::AngleAxis<Scalar>(rotationAngle, vRotationAxis));
133 qRotation = qRotation.normalized();
134 vLocalUp = qRotation * vLocalUp;
136 rotationAngle = Eigen::internal::random<Scalar>(Scalar(-M_PI / 16.), Scalar(M_PI / 16.));
137 vRotationAxis = vLocalFront;
138 qRotation = QuaternionType(Eigen::AngleAxis<Scalar>(rotationAngle, vRotationAxis));
139 qRotation = qRotation.normalized();
140 vLocalUp = qRotation * vLocalUp;
145 const float reverse = Eigen::internal::random<float>(0.f, 1.f);
147 vLocalUp = -vLocalUp;
151 return DataPoint(vRandomPoint, vLocalUp);
183 const typename DataPoint::Scalar _a,
184 const typename DataPoint::Scalar _b,
185 const typename DataPoint::Scalar _s,
186 const bool _bAddNoise =
true
188 typedef typename DataPoint::Scalar Scalar;
189 typedef typename DataPoint::VectorType VectorType;
192 VectorType vPosition;
194 const Scalar x = Eigen::internal::random<Scalar>(-_s, _s),
195 y = Eigen::internal::random<Scalar>(-_s, _s);
197 vPosition = { x, y, internal::getParaboloidZ(x, y, _a, _b)};
198 vNormal = internal::getParaboloidNormal(vPosition, _a, _b);
201 vPosition += VectorType::Random().normalized() * Eigen::internal::random<Scalar>(Scalar(0), Scalar(1. - MIN_NOISE));
203 return DataPoint(vPosition, vNormal);
209 typedef typename DataPoint::VectorType VectorType;
210 typedef typename DataPoint::Scalar Scalar;
211 const VectorType n = VectorType::Random().normalized();
212 const VectorType p = n * Eigen::internal::random<Scalar>(MIN_NOISE, MAX_NOISE);
213 return {p, (n + VectorType::Random()*Scalar(0.1)).normalized()};
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 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.