15#include "up_tri_mat.h"
16#include "low_tri_mat.h"
17#include "quaternion.h"
30 unsigned long long u,v,w;
37 v = 4101842887655102017LL;
39 unsigned long long ull;
48 unsigned long long seed = clock();
53 random(
unsigned long long seed) : storedval(0.0)
61 u = u*2862933555777941757LL + 7046029254386353087LL;
62 v ^= v >> 17; v ^= v <<31; v ^= v >> 8;
63 w = 4294957665U*(w & 0xffffffff) + (w >> 32);
64 unsigned long long x = u ^(u << 21); x ^= x >>35; x^=x << 4;
103 unsigned long long v;
109 void uniform(
const unsigned min,
const unsigned max,
unsigned& rv)
112 rv =rv%(max-min+1)+min;
116 void uniform(
const int min,
const int max,
int& rv)
119 rv =(int)(rv%(
unsigned)(max-min+1))+min;
126 unsigned long long v;
128 rv= 5.42101086242752217E-20 * v;
132 void uniform(
const double min,
const double max,
double &rv)
136 rv= (max-min)*v + min;
148 void uniform(
const float min,
const float max,
float& rv)
152 rv= (max-min)*f + min;
158 for(
unsigned i = 0; i < rv.
size();i++)
165 for(
unsigned i = 0; i < rv.
size();i++)
174 for(
unsigned i = 0; i < rv.
size();i++)
181 for(
unsigned i = 0; i < rv.
size();i++)
186 template<
typename T, cgv::type::u
int32_type N>
189 for(
unsigned i = 0; i < N; i++)
194 template<
typename T, cgv::type::u
int32_type N>
197 for(
unsigned i = 0; i < N; i++)
204 for(
unsigned i = 0; i < rv.
nrows(); i++)
205 for(
unsigned j = 0; j < rv.
ncols(); j++)
212 for(
unsigned i = 0; i < rv.
nrows(); i++)
213 for(
unsigned j = 0; j < rv.
ncols(); j++)
221 for(
unsigned i = 0; i < rv.
size();i++)
232 for(
unsigned i = 0; i < rv.nrows(); i++)
233 for(
unsigned j = i; j < rv.ncols(); j++)
242 for(
unsigned i = 0; i < rv.nrows(); i++)
243 for(
unsigned j = i; j < rv.ncols(); j++)
250 for(
unsigned i = 0; i < rv.nrows(); i++)
251 for(
unsigned j = i; j < rv.ncols(); j++)
258 for(
unsigned i = 0; i < rv.nrows(); i++)
259 for(
unsigned j = i; j < rv.ncols(); j++)
266 for(
unsigned i = 0; i < rv.nrows(); i++)
267 for(
unsigned j = 0; j <= i; j++)
274 for(
unsigned i = 0; i < rv.nrows(); i++)
275 for(
unsigned j = 0; j <= i; j++)
282 for(
unsigned j = 0; j < rv.ncols(); j++)
283 for(
unsigned i = 0; i < j; i++)
290 for(
unsigned j = 0; j < rv.ncols(); j++)
291 for(
unsigned i = 0; i < j; i++)
298 for(
unsigned i = 0; i < rv.
nrows(); i++)
305 for(
unsigned i = 0; i < rv.
nrows(); i++)
312 for(
unsigned i = 0; i < rv.
nrows(); i++)
319 for(
unsigned i = 0; i < rv.
nrows(); i++)
327 for(
unsigned i = 0; i < rv.
nrows(); i++)
328 for(
unsigned j = 0; j < rv.
ncols(); j++)
335 for(
unsigned i = 0; i < rv.
nrows(); i++)
336 for(
unsigned j = 0; j < rv.
ncols(); j++)
345 double v1,v2,rsq,fac;
355 }
while(rsq >= 1.0 || rsq == 0.0);
356 fac = sqrt(-2.0*std::log(rsq)/rsq);
377 void normal(
const double mu,
const double sigma,
double &rv)
385 void normal(
const float mu,
const float sigma,
float& rv)
395 for(
unsigned i = 0;i < v.
size(); i++)
404 for(
unsigned i = 0;i < v.
size();i++)
417 T z, r, theta, omega;
421 theta =
static_cast<T
>(2.0 * cgv::math::constants::pi) * x[1];
422 omega =
static_cast<T
>(cgv::math::constants::pi) * x[2];
426 b = s * cos(theta) * r;
427 c = s * sin(theta) * r;
458 for (
unsigned i=0; i<p.
size(); ++i)
468 for (
unsigned i=0; i<p.
size(); ++i)
478 r = std::pow(r, 1.0/p.
size());
492 p= u*p1 + v*p2 +(1.0-u-v)*p3;
499 for(
unsigned i = 0;i < p.
size();i++)
509 std::set<unsigned> s;
519 for(std::set<unsigned>::iterator it =s.begin(); it != s.end();it++,i++)
matrix of fixed size dimensions
A vector with zero based index.
A matrix type (full column major storage) The matrix can be loaded directly into OpenGL without need ...
unsigned ncols() const
number of columns
unsigned nrows() const
number of rows
void set(AxisEnum axis, coord_type angle)
set quaternion from coordinate axis and rotation angle
void put_homogeneous_matrix(hmat_type &M) const
compute equivalent homogeneous 4x4 rotation matrix
void put_matrix(mat_type &M) const
compute equivalent 3x3 rotation matrix
void resize(unsigned dim)
resize the vector
unsigned size() const
number of elements
void normalize()
normalize the vector using the L2-Norm
A diagonal matrix type which internally stores the elements on the main diagonal in a vector.
unsigned nrows() const
number of rows
a permutation matrix type
unsigned size() const
number of stored elements
High quality random number generator, which is a little bit slower than typical random number generat...
void normal(double &rv)
generates a normal deviate double-precision floating point value with mu = 0 and sigma = 1
void uniform(low_tri_mat< double > &rv)
generates a pseudo random double precision lower triangular matrix with uniformly distribute componen...
void uniform(vec< float > &rv)
generates a pseudo random single precision vector with uniformly distribute components between 0 and ...
void uniform(mat< float > &rv)
generates a pseudo random single precision full matrix with uniformly distribute components between 0...
void normal(const double mu, const double sigma, double &rv)
generates a normal deviate double-precision floating point value with mu and sigma
void uniform(unsigned int &rv)
generates a 32bit pseudo random unsigned integer
void uniform_point_on_sphere(const vec< double > ¢er, const double &radius, vec< double > &p)
creates an uniform distributed random point on the surface of a sphere with given center and radius
void uniform_quat_orientation(quaternion< T > &q)
generates a random orientation represented as a unit quaternion
void uniform(const double min, const double max, double &rv)
generates a pseudo random double-precision floating point number uniformly distributed between min an...
void uniform(const double min, const double max, up_tri_mat< double > &rv)
generates a pseudo random double precision upper triangular matrix with uniformly distribute componen...
void uniform(const float min, const float max, mat< float > &rv)
generates a pseudo random single precision full matrix with uniformly distribute components between m...
void uniform_point_in_triangle(const vec< double > &p1, const vec< double > &p2, const vec< double > &p3, vec< double > p)
creates an uniform distributed random point in triangle p1,p2,p3
void uniform(long &rv)
generates a 32bit pseudo random signed integer
void uniform(diag_mat< double > &rv)
generates a pseudo random double precision diagonal matrix with uniformly distribute components betwe...
void uniform(const float min, const float max, vec< float > &rv)
generates a pseudo random single precision vector with uniformly distribute components between min an...
void uniform_orientation(fmat< T, 3, 3 > &m)
generates a single precision random orientation represented as a rotation matrix
void uniform(float &rv)
generates a pseudo random single-precision floating point number uniformly distributed between 0 and ...
void uniform_direction(vec< double > &v)
generates a double precision random direction (uniformly distributed position on the unit sphere)
void uniform(diag_mat< float > &rv)
generates a pseudo random single precision diagonal matrix with uniformly distribute components betwe...
void uniform_orientation(fmat< T, 4, 4 > &m)
generates a single precision random orientation represented as a homogeneous rotation matrix
void set_seed(unsigned long long seed)
set a new seed
void uniform(const double min, const double max, mat< double > &rv)
generates a pseudo random double full matrix with uniformly distribute components between min and max
void uniform_point_in_unit_ball(vec< double > &p)
creates an uniform distributed random point in unit sphere
void uniform_direction(vec< float > &v)
generates a single precision random direction (uniformly distributed position on the unit sphere)
void uniform(const unsigned min, const unsigned max, unsigned &rv)
generates a pseudo random integer between min and max
void uniform(const double min, const double max, low_tri_mat< double > &rv)
generates a pseudo random double precision lower triangular matrix with uniformly distribute componen...
void uniform(low_tri_mat< float > &rv)
generates a pseudo random single precision lower triangular matrix with uniformly distribute componen...
void uniform_nchoosek(unsigned n, unsigned k, vec< unsigned > &indices)
creates a vector of k unique indices drawn from 0 to n-1
void uniform_point_in_box(const vec< double > &minp, const vec< double > &maxp, vec< double > &p)
creates an uniform distributed random point in box minp..maxp
void uniform(const float min, const float max, up_tri_mat< float > &rv)
generates a pseudo random single precision upper triangular matrix with uniformly distribute componen...
void uniform(up_tri_mat< double > &rv)
generates a pseudo random double precision upper triangular matrix with uniformly distribute componen...
void uniform(unsigned long long &rv)
generates 64bit pseudo random integer
void normal(float &rv)
generates a normal deviate single-precision floating point value with mu = 0 and sigma = 1
void uniform(mat< double > &rv)
generates a pseudo random double full matrix with uniformly distribute components between 0 and 1
void uniform_point_in_unit_box(vec< double > &p)
creates an uniform distributed random point in unit box (0,0,...,0)..(1,1,...,1); if dim(p)=0,...
void uniform(vec< double > &rv)
generates a pseudo random double precision vector with uniformly distribute components between 0 and ...
void uniform(up_tri_mat< float > &rv)
generates a pseudo random single precision upper triangular matrix with uniformly distribute componen...
void uniform(cgv::math::fvec< T, N > &rv)
generates a pseudo random single precision fixed-size vector with uniformly distribute components bet...
void uniform(bool &rv)
generates a pseudo random boolean
void uniform(const float min, const float max, low_tri_mat< float > &rv)
generates a pseudo random single precision lower triangular matrix with uniformly distribute componen...
void uniform(const float min, const float max, cgv::math::fvec< T, N > &rv)
generates a pseudo random single precision fixed-size vector with uniformly distribute components bet...
void uniform(const int min, const int max, int &rv)
generates a pseudo random integer between min and max
random(unsigned long long seed)
constructor initializes random generator with given seed
void uniform(perm_mat &rv)
generates a pseudo random permutation matrix
void uniform(const double min, const double max, diag_mat< double > &rv)
generates a pseudo random double precision diagonal matrix with uniformly distribute components betwe...
random()
standard constructor uses system time as random seed
void uniform(const float min, const float max, float &rv)
generates a pseudo random single-precision floating point number uniformly distributed between min an...
void uniform(long long &rv)
generates a 64bit pseudo random signed integer
void uniform(const float min, const float max, diag_mat< float > &rv)
generates a pseudo random single precision diagonal matrix with uniformly distribute components betwe...
void uniform(const double min, const double max, vec< double > &rv)
generates a pseudo random double precision vector with uniformly distribute components between min an...
void uniform(int &rv)
generates a 32bit pseudo random signed integer
void uniform(double &rv)
generates a pseudo random double-precision floating point number uniformly distributed between 0 and ...
void normal(const float mu, const float sigma, float &rv)
generates a normal deviate single-precision floating point value with mu and sigma