OpenMPCD
Vector3D.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the Vector3D class.
4  */
5 
6 #ifndef OPENMPCD_VECTOR3D_HPP
7 #define OPENMPCD_VECTOR3D_HPP
8 
10 #include <OpenMPCD/Exceptions.hpp>
11 #include <OpenMPCD/Scalar.hpp>
12 #include <OpenMPCD/Types.hpp>
13 #include <OpenMPCD/TypeTraits.hpp>
17 
18 #ifdef OPENMPCD_PLATFORM_CUDA
19 #include <OpenMPCD/CUDA/Types.hpp>
21 #endif
22 
23 #include <boost/math/constants/constants.hpp>
24 #include <boost/random/uniform_01.hpp>
25 #include <boost/static_assert.hpp>
26 #include <boost/type_traits/is_floating_point.hpp>
27 
28 #include <cmath>
29 #include <complex>
30 #include <ostream>
31 
32 namespace OpenMPCD
33 {
34  /**
35  * 3-dimensional vector.
36  * @tparam T The underlying floating-point type.
37  */
38  template<typename T> class Vector3D
39  {
40  public:
41  typedef typename TypeTraits<T>::RealType RealType; ///< The real-value type matching T.
42 
43  public:
44  /**
45  * Constructs a vector from its coordinates.
46  * @param[in] x_ The x-coordinate.
47  * @param[in] y_ The y-coordinate.
48  * @param[in] z_ The z-coordinate.
49  */
51  Vector3D(const T x_, const T y_, const T z_)
52  : x(x_), y(y_), z(z_)
53  {
54  }
55 
56  public:
57  /**
58  * Returns the x coordinate.
59  */
61  T getX() const
62  {
63  return x;
64  }
65 
66  /**
67  * Sets the x coordinate.
68  * @param[in] val The new value.
69  */
71  void setX(const T val)
72  {
73  x=val;
74  }
75 
76  /**
77  * Adds the given value to the x coordinate.
78  * @param[in] val The value to add
79  */
81  void addToX(const T val)
82  {
83  x+=val;
84  }
85 
86  /**
87  * Returns the y coordinate.
88  */
90  T getY() const
91  {
92  return y;
93  }
94 
95  /**
96  * Sets the y coordinate.
97  * @param[in] val The new value.
98  */
100  void setY(const T val)
101  {
102  y=val;
103  }
104 
105  /**
106  * Adds the given value to the y coordinate.
107  * @param[in] val The value to add
108  */
110  void addToY(const T val)
111  {
112  y+=val;
113  }
114 
115  /**
116  * Returns the z coordinate.
117  */
119  T getZ() const
120  {
121  return z;
122  }
123 
124  /**
125  * Sets the z coordinate.
126  * @param[in] val The new value.
127  */
129  void setZ(const T val)
130  {
131  z=val;
132  }
133 
134  /**
135  * Adds the given value to the z coordinate.
136  * @param[in] val The value to add
137  */
139  void addToZ(const T val)
140  {
141  z+=val;
142  }
143 
144  /**
145  * Sets the coordinates.
146  * @param[in] x_ The x coordinate.
147  * @param[in] y_ The y coordinate.
148  * @param[in] z_ The z coordinate.
149  */
151  void set(const T x_, const T y_, const T z_)
152  {
153  x = x_;
154  y = y_;
155  z = z_;
156  }
157 
158  public:
159  /**
160  * Returns the cross product of this vector with the given vector.
161  * @param[in] rhs The right-hand-side vector.
162  */
164  const Vector3D cross(const Vector3D& rhs) const
165  {
166  const T cx=y*rhs.z-z*rhs.y;
167  const T cy=z*rhs.x-x*rhs.z;
168  const T cz=x*rhs.y-y*rhs.x;
169  return Vector3D(cx, cy, cz);
170  }
171 
172  /**
173  * Returns the scalar product of this vector with the given vector.
174  *
175  * The scalar product is defines such that the left-hand-side's components are complex-conjugated
176  * prior to multiplication with the right-hand-side's components.
177  *
178  * @param[in] rhs The right-hand-side.
179  */
181  const T dot(const Vector3D& rhs) const
182  {
183  return Implementation_Vector3D::Dot<T>::dot(*this, rhs);
184  }
185 
186  /**
187  * Returns the cosine of the angle between this vector and the given one.
188  * @tparam Result The result type.
189  * @param[in] rhs The right-hand-side vector.
190  */
191  T getCosineOfAngle(const Vector3D& rhs) const
192  {
193  return dot(rhs) / (magnitude() * rhs.magnitude());
194  }
195 
196  /**
197  * Returns the the angle between this vector and the given one.
198  * @param[in] rhs The right-hand-side vector.
199  */
200  T getAngle(const Vector3D& rhs) const
201  {
202  return acos(getCosineOfAngle(rhs));
203  }
204 
205  /**
206  * Returns the square of the magnitude of this vector.
207  */
210  {
211  return Scalar::getRealPart(dot(*this));
212  }
213 
214  /**
215  * Returns the square of the magnitude of this vector.
216  */
219  {
220  return getMagnitudeSquared();
221  }
222 
223  /**
224  * Returns the magnitude of this vector.
225  */
228  {
229  return sqrt(getMagnitudeSquared());
230  }
231 
232  /**
233  * Returns the magnitude of this vector.
234  */
237  {
238  return getMagnitude();
239  }
240 
241  /**
242  * Normalizes this vector.
243  *
244  * @throw OpenMPCD::DivisionByZeroException
245  * For Host code, throws if `magnitude() == 0`.
246  */
248  void normalize()
249  {
250  const RealType mag=magnitude();
251 
252  #ifndef __CUDA_ARCH__
253  if(Scalar::isZero(mag))
255  #endif
256 
257  operator/=(mag);
258  }
259 
260  /**
261  * Returns this vector, but normalized.
262  */
264  const Vector3D getNormalized() const
265  {
266  Vector3D tmp(*this);
267  tmp.normalize();
268  return tmp;
269  }
270 
271  /**
272  * Returns the projection of this vector onto the given one.
273  * @param[in] onto The vector to project onto.
274  */
275  const Vector3D getProjectedOnto(const Vector3D& onto) const
276  {
277  const Vector3D normalized = onto.getNormalized();
278  return normalized.dot(*this) * normalized;
279  }
280 
281  /**
282  * Returns the part of this vector that is perpendicular to the given vector.
283  * @param[in] rhs The vector the result should be perpendicular to.
284  */
285  const Vector3D getPerpendicularTo(const Vector3D& rhs) const
286  {
287  return *this - getProjectedOnto(rhs);
288  }
289 
290  /**
291  * Returns the complex version of this vector.
292  *
293  * This function only works if this vector has a real-value type.
294  */
296  {
297  BOOST_STATIC_ASSERT(boost::is_floating_point<T>::value);
298 
299  return Vector3D<std::complex<T> >(x, y, z);
300  }
301 
302  /**
303  * Rotates this vector about the given axis by the given angle.
304  * @param[in] axis The axis to rotate about, which is assumed to be normalized.
305  * @param[in] angle The angle to rotate with.
306  */
308  void rotateAroundNormalizedAxis(const Vector3D& axis, const T angle)
309  {
310  const T thisDotAxis = dot(axis);
311  const Vector3D axisCrossThis = axis.cross(*this);
312  const Vector3D projectionOntoAxis = axis*thisDotAxis;
313  *this = projectionOntoAxis + cos(angle) * (*this - projectionOntoAxis) + sin(angle) * axisCrossThis;
314  }
315 
316  /**
317  * Returns this vector, but rotated about the given axis by the given angle.
318  * @param[in] axis The axis to rotate about, which is assumed to be normalized.
319  * @param[in] angle The angle to rotate with.
320  */
322  const Vector3D getRotatedAroundNormalizedAxis(const Vector3D& axis, const T angle) const
323  {
324  Vector3D tmp(*this);
325  tmp.rotateAroundNormalizedAxis(axis, angle);
326  return tmp;
327  }
328 
329  /**
330  * Returns whether at least one of the components of this vector is negative.
331  */
332  bool hasNegativeComponent() const
333  {
334  return x<0 || y<0 || z<0;
335  }
336 
337  /**
338  * Returns whether all components are finite, i.e. neither infinite nor NaN.
339  */
341  bool isFinite() const
342  {
343  #ifndef __CUDA_ARCH__
344  using std::isfinite;
345  #endif
346 
347  if(!isfinite(x))
348  return false;
349  if(!isfinite(y))
350  return false;
351  if(!isfinite(z))
352  return false;
353 
354  return true;
355  }
356 
357  public:
358  /**
359  * Returns a random vector with unit length;
360  * all directions are equally likely.
361  *
362  * @tparam RNG The random-number-generator type.
363  *
364  * @param[in] rng The random-number-generator.
365  */
366  template<typename RNG> static OPENMPCD_CUDA_HOST
368  {
369  boost::random::uniform_01<T> dist0i1e;
370 
371  //Ideally, X_1 should be sampled from the uniform distribution
372  //over [0,1]
373  const T X_1 = dist0i1e(rng);
374  const T X_2 = dist0i1e(rng);
375 
376  return getUnitVectorFromRandom01(X_1, X_2);
377  }
378 
379  #ifdef OPENMPCD_PLATFORM_CUDA
380  static OPENMPCD_CUDA_DEVICE
382  {
384 
385  //Ideally, X_1 should be sampled from the uniform distribution
386  //over [0,1]
387  T X_1;
388  T X_2;
389  dist0e1i(rng, &X_1, &X_2);
390 
391  return getUnitVectorFromRandom01(X_1, X_2);
392  }
393  #endif
394 
395  /**
396  * Constructs a unit vector from the two given random variables.
397  *
398  * @param[in] X_1
399  * A variable drawn from the uniform distribution on the
400  * closed interval \f$ \left[ 0, 1 \right] \f$.
401  * @param[in] X_2
402  * A variable drawn from the uniform distribution on
403  * either the half-open interval
404  * \f$ \left[ 0, 1 \right) \f$
405  * or the half-open interval \f$ \left( 0, 1 \right] \f$.
406  */
408  const Vector3D getUnitVectorFromRandom01(const T X_1, const T X_2)
409  {
411 
412  const T z = 2 * X_1 - 1;
413  const T phiOverPi = 2 * X_2;
414 
415  const T root = MF::sqrt(1 - z*z);
416 
417  T x;
418  T y;
419  MF::sincospi(phiOverPi, &y, &x);
420 
421  x *= root;
422  y *= root;
423 
424  return Vector3D(x, y, z);
425  }
426 
427  public:
428  /**
429  * Equality operator.
430  * @param[in] rhs The right-hand-side vector.
431  */
433  bool operator==(const Vector3D& rhs) const
434  {
435  if(x == rhs.x && y == rhs.y && z == rhs.z)
436  return true;
437  return false;
438  }
439 
440  /**
441  * Inequality operator.
442  * @param[in] rhs The right-hand-side vector.
443  */
445  bool operator!=(const Vector3D& rhs) const
446  {
447  return !operator==(rhs);
448  }
449 
450  /**
451  * Addition-and-assignment operator.
452  * @param[in] rhs The right-hand-side vector.
453  * @return Returns this instance.
454  */
456  const Vector3D& operator+=(const Vector3D& rhs)
457  {
458  x+=rhs.x;
459  y+=rhs.y;
460  z+=rhs.z;
461 
462  return *this;
463  }
464 
465  /**
466  * Addition operator.
467  * @param[in] rhs The right-hand-side vector.
468  * @return Returns this instance.
469  */
471  const Vector3D operator+(const Vector3D& rhs) const
472  {
473  Vector3D tmp(*this);
474  return tmp+=rhs;
475  }
476 
477  /**
478  * Subtraction-and-assignment operator.
479  * @param[in] rhs The right-hand-side vector.
480  * @return Returns this instance.
481  */
483  const Vector3D& operator-=(const Vector3D& rhs)
484  {
485  x-=rhs.x;
486  y-=rhs.y;
487  z-=rhs.z;
488 
489  return *this;
490  }
491 
492  /**
493  * Subtraction operator.
494  * @param[in] rhs The right-hand-side vector.
495  * @return Returns this instance.
496  */
498  const Vector3D operator-(const Vector3D& rhs) const
499  {
500  Vector3D tmp(*this);
501  return tmp-=rhs;
502  }
503 
504  /**
505  * The negation operator.
506  */
508  const Vector3D operator-() const
509  {
510  return operator*(-1);
511  }
512 
513  /**
514  * Scalar multiplication and assignment operator.
515  * @param[in] scale The scaling factor.
516  * @return Returns this instance.
517  */
519  const Vector3D& operator*=(const T scale)
520  {
521  x*=scale;
522  y*=scale;
523  z*=scale;
524 
525  return *this;
526  }
527 
528  /**
529  * Scalar multiplication operator.
530  * @param[in] scale The scaling factor.
531  */
533  const Vector3D operator*(const T scale) const
534  {
535  Vector3D tmp(*this);
536  return tmp*=scale;
537  }
538 
539  /**
540  * Scalar multiplication operator.
541  * @param[in] scale The scaling factor.
542  * @param[in] vec The vector to multiply.
543  */
545  friend const Vector3D operator*(const T scale, const Vector3D& vec)
546  {
547  return vec*scale;
548  }
549 
550  /**
551  * Scalar division and assignment operator.
552  * @throw OpenMPCD::DivisionByZeroException
553  * For Host code, throws if divisor is 0.
554  * @param[in] divisor The divisor.
555  * @return Returns this instance.
556  */
558  const Vector3D& operator/=(const T divisor)
559  {
560  #ifndef __CUDA_ARCH__
561  if(Scalar::isZero(divisor))
563  #endif
564 
565  x/=divisor;
566  y/=divisor;
567  z/=divisor;
568 
569  return *this;
570  }
571 
572  /**
573  * Scalar division operator.
574  * @throw DivisionByZeroExcpetion For Host code, throws if divisor is 0.
575  * @param[in] divisor The divisor.
576  */
578  const Vector3D operator/(const T divisor) const
579  {
580  Vector3D tmp(*this);
581  return tmp/=divisor;
582  }
583 
584  /**
585  * Less-than operator.
586  * Compares, in this order, the x, y, and z components.
587  * @param[in] rhs The right-hand-side instance.
588  */
589  bool operator<(const Vector3D& rhs) const
590  {
591  if(x < rhs.x)
592  return true;
593 
594  if(x > rhs.x)
595  return false;
596 
597  if(y < rhs.y)
598  return true;
599 
600  if(y > rhs.y)
601  return false;
602 
603  if(z < rhs.z)
604  return true;
605 
606  return false;
607  }
608 
609  /**
610  * Output operator for streams.
611  * @param[in] stream The stream to print to.
612  * @param[in] vector The vector to print.
613  */
614  friend std::ostream& operator<<(std::ostream& stream, const Vector3D& vector)
615  {
616  stream<<vector.x<<" "<<vector.y<<" "<<vector.z;
617  return stream;
618  }
619 
620  private:
621  T x; ///< The x-coordinate.
622  T y; ///< The y-coordinate.
623  T z; ///< The z-coordinate.
624  };
625 }
626 
628 
629 #endif
OpenMPCD::Vector3D::operator<
bool operator<(const Vector3D &rhs) const
Less-than operator.
Definition: Vector3D.hpp:589
PlatformDetection.hpp
OpenMPCD::Vector3D::isFinite
OPENMPCD_CUDA_HOST_AND_DEVICE bool isFinite() const
Returns whether all components are finite, i.e.
Definition: Vector3D.hpp:341
OpenMPCD::Vector3D::hasNegativeComponent
bool hasNegativeComponent() const
Returns whether at least one of the components of this vector is negative.
Definition: Vector3D.hpp:332
OpenMPCD::Vector3D::getRotatedAroundNormalizedAxis
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getRotatedAroundNormalizedAxis(const Vector3D &axis, const T angle) const
Returns this vector, but rotated about the given axis by the given angle.
Definition: Vector3D.hpp:322
OpenMPCD::Vector3D::magnitudeSquared
OPENMPCD_CUDA_HOST_AND_DEVICE RealType magnitudeSquared() const
Returns the square of the magnitude of this vector.
Definition: Vector3D.hpp:218
OpenMPCD::Scalar::isZero
OPENMPCD_CUDA_HOST_AND_DEVICE boost::enable_if< boost::is_floating_point< T >, bool >::type isZero(const T &val)
Returns whether the given value is zero.
Definition: Scalar.hpp:66
Exceptions.hpp
OpenMPCD::Vector3D::getZ
OPENMPCD_CUDA_HOST_AND_DEVICE T getZ() const
Returns the z coordinate.
Definition: Vector3D.hpp:119
Uniform0e1i.hpp
OPENMPCD_THROW
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
Definition: Exceptions.hpp:22
Vector3D_Implementation2.hpp
OpenMPCD::Utility::MathematicalFunctions::cos
OPENMPCD_CUDA_HOST_AND_DEVICE T cos(const T x)
Returns the cosine of the argument.
OpenMPCD::Vector3D
3-dimensional vector.
Definition: Vector3D.hpp:38
OpenMPCD::Vector3D::operator==
OPENMPCD_CUDA_HOST_AND_DEVICE bool operator==(const Vector3D &rhs) const
Equality operator.
Definition: Vector3D.hpp:433
OpenMPCD::Vector3D::dot
const OPENMPCD_CUDA_HOST_AND_DEVICE T dot(const Vector3D &rhs) const
Returns the scalar product of this vector with the given vector.
Definition: Vector3D.hpp:181
OpenMPCD::TypeTraits
Contains information on certain types.
Definition: TypeTraits.hpp:46
OpenMPCD::Vector3D::getX
OPENMPCD_CUDA_HOST_AND_DEVICE T getX() const
Returns the x coordinate.
Definition: Vector3D.hpp:61
Types.hpp
OpenMPCD::Vector3D::operator-
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D operator-(const Vector3D &rhs) const
Subtraction operator.
Definition: Vector3D.hpp:498
OpenMPCD::Vector3D::normalize
OPENMPCD_CUDA_HOST_AND_DEVICE void normalize()
Normalizes this vector.
Definition: Vector3D.hpp:248
OpenMPCD::Vector3D::rotateAroundNormalizedAxis
OPENMPCD_CUDA_HOST_AND_DEVICE void rotateAroundNormalizedAxis(const Vector3D &axis, const T angle)
Rotates this vector about the given axis by the given angle.
Definition: Vector3D.hpp:308
OpenMPCD::Vector3D::getComplexVector
const Vector3D< std::complex< T > > getComplexVector() const
Returns the complex version of this vector.
Definition: Vector3D.hpp:295
OpenMPCD::Vector3D::operator*=
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & operator*=(const T scale)
Scalar multiplication and assignment operator.
Definition: Vector3D.hpp:519
OPENMPCD_CUDA_DEVICE
#define OPENMPCD_CUDA_DEVICE
Denotes a function to be callable from a CUDA Device.
Definition: Macros.hpp:25
OPENMPCD_CUDA_HOST_AND_DEVICE
#define OPENMPCD_CUDA_HOST_AND_DEVICE
Denotes a function to be callable both from the Host and from a CUDA Device.
Definition: Macros.hpp:15
OpenMPCD::Vector3D::operator+
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D operator+(const Vector3D &rhs) const
Addition operator.
Definition: Vector3D.hpp:471
OpenMPCD::Vector3D::operator<<
friend std::ostream & operator<<(std::ostream &stream, const Vector3D &vector)
Output operator for streams.
Definition: Vector3D.hpp:614
OpenMPCD::Vector3D::getY
OPENMPCD_CUDA_HOST_AND_DEVICE T getY() const
Returns the y coordinate.
Definition: Vector3D.hpp:90
OpenMPCD::Vector3D::addToX
OPENMPCD_CUDA_HOST_AND_DEVICE void addToX(const T val)
Adds the given value to the x coordinate.
Definition: Vector3D.hpp:81
OpenMPCD::Vector3D::operator+=
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & operator+=(const Vector3D &rhs)
Addition-and-assignment operator.
Definition: Vector3D.hpp:456
OpenMPCD::Vector3D::operator/
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D operator/(const T divisor) const
Scalar division operator.
Definition: Vector3D.hpp:578
OpenMPCD::CUDA::Random::Distributions::Uniform0e1i
The uniform distribution in the left-open interval .
Definition: Uniform0e1i.hpp:36
OpenMPCD::Vector3D::getUnitVectorFromRandom01
static const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getUnitVectorFromRandom01(const T X_1, const T X_2)
Constructs a unit vector from the two given random variables.
Definition: Vector3D.hpp:408
TypeTraits.hpp
OpenMPCD::Vector3D::getAngle
T getAngle(const Vector3D &rhs) const
Returns the the angle between this vector and the given one.
Definition: Vector3D.hpp:200
OpenMPCD::DivisionByZeroException
Division by zero.
Definition: Exceptions.hpp:176
OpenMPCD::Vector3D::getNormalized
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getNormalized() const
Returns this vector, but normalized.
Definition: Vector3D.hpp:264
OpenMPCD::RNG
boost::mt11213b RNG
The random number generator type.
Definition: Types.hpp:18
OpenMPCD::Vector3D::operator*
OPENMPCD_CUDA_HOST_AND_DEVICE const friend Vector3D operator*(const T scale, const Vector3D &vec)
Scalar multiplication operator.
Definition: Vector3D.hpp:545
OpenMPCD::Vector3D::addToZ
OPENMPCD_CUDA_HOST_AND_DEVICE void addToZ(const T val)
Adds the given value to the z coordinate.
Definition: Vector3D.hpp:139
OpenMPCD::Implementation_Vector3D::Dot::dot
static const OPENMPCD_CUDA_HOST_AND_DEVICE T dot(const Vector3D< T > &lhs, const Vector3D< T > &rhs)
Returns the scalar product two vectors.
OpenMPCD::Vector3D::operator-
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D operator-() const
The negation operator.
Definition: Vector3D.hpp:508
OpenMPCD::Vector3D::getProjectedOnto
const Vector3D getProjectedOnto(const Vector3D &onto) const
Returns the projection of this vector onto the given one.
Definition: Vector3D.hpp:275
OpenMPCD::Vector3D::magnitude
OPENMPCD_CUDA_HOST_AND_DEVICE RealType magnitude() const
Returns the magnitude of this vector.
Definition: Vector3D.hpp:236
OPENMPCD_CUDA_HOST
#define OPENMPCD_CUDA_HOST
Denotes a function to be callable from the Host.
Definition: Macros.hpp:20
OpenMPCD::Vector3D::cross
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D cross(const Vector3D &rhs) const
Returns the cross product of this vector with the given vector.
Definition: Vector3D.hpp:164
OpenMPCD::Vector3D::operator*
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D operator*(const T scale) const
Scalar multiplication operator.
Definition: Vector3D.hpp:533
Types.hpp
MathematicalFunctions.hpp
OpenMPCD::Vector3D::getRandomUnitVector
static const OPENMPCD_CUDA_HOST Vector3D getRandomUnitVector(RNG &rng)
Returns a random vector with unit length; all directions are equally likely.
Definition: Vector3D.hpp:367
OpenMPCD::Vector3D::getCosineOfAngle
T getCosineOfAngle(const Vector3D &rhs) const
Returns the cosine of the angle between this vector and the given one.
Definition: Vector3D.hpp:191
OpenMPCD::Utility::MathematicalFunctions::sincospi
OPENMPCD_CUDA_HOST_AND_DEVICE void sincospi(const T x, T *const s, T *const c)
Computes both the sine and the cosine of the product of the argument and .
OpenMPCD::Vector3D::setX
OPENMPCD_CUDA_HOST_AND_DEVICE void setX(const T val)
Sets the x coordinate.
Definition: Vector3D.hpp:71
Macros.hpp
OpenMPCD::Vector3D::set
OPENMPCD_CUDA_HOST_AND_DEVICE void set(const T x_, const T y_, const T z_)
Sets the coordinates.
Definition: Vector3D.hpp:151
OpenMPCD::Vector3D::addToY
OPENMPCD_CUDA_HOST_AND_DEVICE void addToY(const T val)
Adds the given value to the y coordinate.
Definition: Vector3D.hpp:110
OpenMPCD::Vector3D::Vector3D
OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D(const T x_, const T y_, const T z_)
Constructs a vector from its coordinates.
Definition: Vector3D.hpp:51
OpenMPCD::Vector3D::setY
OPENMPCD_CUDA_HOST_AND_DEVICE void setY(const T val)
Sets the y coordinate.
Definition: Vector3D.hpp:100
OpenMPCD::Utility::MathematicalFunctions::sqrt
OPENMPCD_CUDA_HOST_AND_DEVICE T sqrt(const T x)
Returns the sqaure root of the argument.
OpenMPCD::Vector3D::operator/=
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & operator/=(const T divisor)
Scalar division and assignment operator.
Definition: Vector3D.hpp:558
OpenMPCD::Utility::MathematicalFunctions
Defines common mathematical functions.
Definition: ImplementationDetails/MathematicalFunctions.hpp:22
OpenMPCD::Vector3D::getPerpendicularTo
const Vector3D getPerpendicularTo(const Vector3D &rhs) const
Returns the part of this vector that is perpendicular to the given vector.
Definition: Vector3D.hpp:285
Vector3D_Implementation1.hpp
OpenMPCD::Vector3D::operator!=
OPENMPCD_CUDA_HOST_AND_DEVICE bool operator!=(const Vector3D &rhs) const
Inequality operator.
Definition: Vector3D.hpp:445
OpenMPCD::Scalar::getRealPart
OPENMPCD_CUDA_HOST_AND_DEVICE boost::enable_if< boost::is_floating_point< T >, T >::type getRealPart(const T &val)
Returns the real part of the given value.
Definition: Scalar.hpp:37
OpenMPCD::Vector3D::RealType
TypeTraits< T >::RealType RealType
The real-value type matching T.
Definition: Vector3D.hpp:41
OpenMPCD::CUDA::Random::Generators::Philox4x32_10
Philox4x32-10 counter-bases PRNG.
Definition: Philox4x32-10.hpp:30
OpenMPCD::Utility::MathematicalFunctions::acos
OPENMPCD_CUDA_HOST_AND_DEVICE T acos(const T x)
Returns the arc cosine of the argument.
OpenMPCD::Vector3D::getMagnitude
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitude() const
Returns the magnitude of this vector.
Definition: Vector3D.hpp:227
OpenMPCD::Vector3D::operator-=
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & operator-=(const Vector3D &rhs)
Subtraction-and-assignment operator.
Definition: Vector3D.hpp:483
OpenMPCD::Utility::MathematicalFunctions::sin
OPENMPCD_CUDA_HOST_AND_DEVICE T sin(const T x)
Returns the sine of the argument.
OpenMPCD::Vector3D::setZ
OPENMPCD_CUDA_HOST_AND_DEVICE void setZ(const T val)
Sets the z coordinate.
Definition: Vector3D.hpp:129
OpenMPCD::Vector3D::getMagnitudeSquared
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitudeSquared() const
Returns the square of the magnitude of this vector.
Definition: Vector3D.hpp:209
Scalar.hpp