Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
random_xyz.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file numeric/random/random_xyz.hh
11 /// @brief Random vectors and stuff
12 /// @author Will Sheffler
13 
15 
16 namespace numeric {
17 namespace random {
18 
19 using numeric::Real;
20 using namespace numeric;
21 using namespace numeric::random;
22 
25 }
27  return xyzVector<Real>(uniform(),uniform(),uniform());
28 
29 }
31  return random_vector_spherical();
32 }
34  return random_vector_spherical().normalized();
35 }
36 
37 // cheaper to use gaussian, or do sines?
39  Real u1=uniform();
42  Real sinu2 = sin(u2);
43  Real sinu3 = sin(u3);
44  Real cosu2 = sqrt(1.0-sinu2*sinu2);
45  Real cosu3 = sqrt(1.0-sinu3*sinu3);
46  return Quaternion<Real>( sqrt(1-u1)*sinu2,
47  sqrt(1-u1)*cosu2,
48  sqrt( u1)*sinu3,
49  sqrt( u1)*cosu3 );
50 }
53  return xyzMatrix<Real>::cols(
54  1.0 - 2.0*q.y()*q.y() - 2.0*q.z()*q.z(), 2.0*q.x()*q.y() - 2.0*q.z()*q.w(), 2.0*q.x()*q.z() + 2.0*q.y()*q.w(),
55  2.0*q.x()*q.y() + 2.0*q.z()*q.w(), 1.0 - 2.0*q.x()*q.x() - 2.0*q.z()*q.z(), 2.0*q.y()*q.z() - 2.0*q.x()*q.w(),
56  2.0*q.x()*q.z() - 2.0*q.y()*q.w(), 2.0*q.y()*q.z() + 2.0*q.x()*q.w(), 1.0 - 2.0*q.x()*q.x() - 2.0*q.y()*q.y()
57  );
58 }
61 }
62 
63 xyzTransform<Real> gaussian_random_xform(Real const & angsd, Real const & movsd){
64  return xyzTransform<Real>(
66  movsd*xyzVector<Real>( gaussian(),gaussian(),gaussian()) );
67 }
68 
69 
70 } // namespace random
71 } // namespace numeric
72 
xyzVector< Real > random_vector_unit_cube()
Definition: random_xyz.cc:26
xyzVector< Real > random_vector_spherical()
Definition: random_xyz.cc:23
Value const & w() const
w
Definition: Quaternion.hh:158
xyzVector< Real > random_vector()
Definition: random_xyz.cc:30
Quaternion< Real > random_unit_quaternion()
Definition: random_xyz.cc:38
xyzTransform< Real > random_xform()
Definition: random_xyz.cc:59
double gaussian()
Generate a random number pulled from a standard normal – i.e. mean of zero and standard deviation of...
Definition: random.cc:57
xyzVector: Fast (x,y,z)-coordinate numeric vector
Value const & x() const
x
Definition: Quaternion.hh:167
xyzMatrix< Real > random_rotation()
Definition: random_xyz.cc:51
double Real
Definition: types.hh:39
xyzTransform< Real > gaussian_random_xform(Real const &angsd, Real const &movsd)
Definition: random_xyz.cc:63
Random vectors and stuff.
xyzMatrix< T > rotation_matrix_degrees(xyzVector< T > const &axis, T const &theta)
Rotation matrix for rotation about an axis by an angle in degrees.
xyzMatrix: Fast 3x3 xyz matrix template
Value const & y() const
y
Definition: Quaternion.hh:176
double uniform()
Generate a random number between 0 and 1. Threadsafe since each thread uses its own random generator...
Definition: random.cc:56
xyzVector< Real > random_normal()
Definition: random_xyz.cc:33
Value const & z() const
z
Definition: Quaternion.hh:185
Unit quaternion 3-D orientation representation.
static xyzMatrix cols(Value const &xx_a, Value const &yx_a, Value const &zx_a, Value const &xy_a, Value const &yy_a, Value const &zy_a, Value const &xz_a, Value const &yz_a, Value const &zz_a)
Column-ordered value named constructor.
Definition: xyzMatrix.hh:146