OpenMPCD
|
3-dimensional vector. More...
#include <Vector3D.hpp>
Public Types | |
typedef TypeTraits< T >::RealType | RealType |
The real-value type matching T. More... | |
Public Member Functions | |
OPENMPCD_CUDA_HOST_AND_DEVICE | Vector3D (const T x_, const T y_, const T z_) |
Constructs a vector from its coordinates. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE T | getX () const |
Returns the x coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | setX (const T val) |
Sets the x coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | addToX (const T val) |
Adds the given value to the x coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE T | getY () const |
Returns the y coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | setY (const T val) |
Sets the y coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | addToY (const T val) |
Adds the given value to the y coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE T | getZ () const |
Returns the z coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | setZ (const T val) |
Sets the z coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | addToZ (const T val) |
Adds the given value to the z coordinate. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | set (const T x_, const T y_, const T z_) |
Sets the coordinates. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | cross (const Vector3D &rhs) const |
Returns the cross product of this vector with the given vector. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE T | dot (const Vector3D &rhs) const |
Returns the scalar product of this vector with the given vector. More... | |
T | getCosineOfAngle (const Vector3D &rhs) const |
Returns the cosine of the angle between this vector and the given one. More... | |
T | getAngle (const Vector3D &rhs) const |
Returns the the angle between this vector and the given one. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE RealType | getMagnitudeSquared () const |
Returns the square of the magnitude of this vector. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE RealType | magnitudeSquared () const |
Returns the square of the magnitude of this vector. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE RealType | getMagnitude () const |
Returns the magnitude of this vector. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE RealType | magnitude () const |
Returns the magnitude of this vector. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | normalize () |
Normalizes this vector. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | getNormalized () const |
Returns this vector, but normalized. More... | |
const Vector3D | getProjectedOnto (const Vector3D &onto) const |
Returns the projection of this vector onto the given one. More... | |
const Vector3D | getPerpendicularTo (const Vector3D &rhs) const |
Returns the part of this vector that is perpendicular to the given vector. More... | |
const Vector3D< std::complex< T > > | getComplexVector () const |
Returns the complex version of this vector. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE void | rotateAroundNormalizedAxis (const Vector3D &axis, const T angle) |
Rotates this vector about the given axis by the given angle. More... | |
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. More... | |
bool | hasNegativeComponent () const |
Returns whether at least one of the components of this vector is negative. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE bool | isFinite () const |
Returns whether all components are finite, i.e. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE bool | operator== (const Vector3D &rhs) const |
Equality operator. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE bool | operator!= (const Vector3D &rhs) const |
Inequality operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & | operator+= (const Vector3D &rhs) |
Addition-and-assignment operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | operator+ (const Vector3D &rhs) const |
Addition operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & | operator-= (const Vector3D &rhs) |
Subtraction-and-assignment operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | operator- (const Vector3D &rhs) const |
Subtraction operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | operator- () const |
The negation operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & | operator*= (const T scale) |
Scalar multiplication and assignment operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | operator* (const T scale) const |
Scalar multiplication operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D & | operator/= (const T divisor) |
Scalar division and assignment operator. More... | |
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D | operator/ (const T divisor) const |
Scalar division operator. More... | |
bool | operator< (const Vector3D &rhs) const |
Less-than operator. More... | |
Static Public Member Functions | |
template<typename RNG > | |
static const OPENMPCD_CUDA_HOST Vector3D | getRandomUnitVector (RNG &rng) |
Returns a random vector with unit length; all directions are equally likely. More... | |
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. More... | |
Friends | |
OPENMPCD_CUDA_HOST_AND_DEVICE const friend Vector3D | operator* (const T scale, const Vector3D &vec) |
Scalar multiplication operator. More... | |
std::ostream & | operator<< (std::ostream &stream, const Vector3D &vector) |
Output operator for streams. More... | |
3-dimensional vector.
T | The underlying floating-point type. |
Definition at line 38 of file Vector3D.hpp.
typedef TypeTraits<T>::RealType OpenMPCD::Vector3D< T >::RealType |
The real-value type matching T.
Definition at line 41 of file Vector3D.hpp.
|
inline |
Constructs a vector from its coordinates.
[in] | x_ | The x-coordinate. |
[in] | y_ | The y-coordinate. |
[in] | z_ | The z-coordinate. |
Definition at line 51 of file Vector3D.hpp.
|
inline |
Adds the given value to the x coordinate.
[in] | val | The value to add |
Definition at line 81 of file Vector3D.hpp.
|
inline |
Adds the given value to the y coordinate.
[in] | val | The value to add |
Definition at line 110 of file Vector3D.hpp.
|
inline |
Adds the given value to the z coordinate.
[in] | val | The value to add |
Definition at line 139 of file Vector3D.hpp.
|
inline |
Returns the cross product of this vector with the given vector.
[in] | rhs | The right-hand-side vector. |
Definition at line 164 of file Vector3D.hpp.
|
inline |
Returns the scalar product of this vector with the given vector.
The scalar product is defines such that the left-hand-side's components are complex-conjugated prior to multiplication with the right-hand-side's components.
[in] | rhs | The right-hand-side. |
Definition at line 181 of file Vector3D.hpp.
|
inline |
Returns the the angle between this vector and the given one.
[in] | rhs | The right-hand-side vector. |
Definition at line 200 of file Vector3D.hpp.
|
inline |
Returns the complex version of this vector.
This function only works if this vector has a real-value type.
Definition at line 295 of file Vector3D.hpp.
|
inline |
Returns the cosine of the angle between this vector and the given one.
Result | The result type. |
[in] | rhs | The right-hand-side vector. |
Definition at line 191 of file Vector3D.hpp.
|
inline |
Returns the magnitude of this vector.
Definition at line 227 of file Vector3D.hpp.
|
inline |
Returns the square of the magnitude of this vector.
Definition at line 209 of file Vector3D.hpp.
|
inline |
Returns this vector, but normalized.
Definition at line 264 of file Vector3D.hpp.
|
inline |
Returns the part of this vector that is perpendicular to the given vector.
[in] | rhs | The vector the result should be perpendicular to. |
Definition at line 285 of file Vector3D.hpp.
|
inline |
Returns the projection of this vector onto the given one.
[in] | onto | The vector to project onto. |
Definition at line 275 of file Vector3D.hpp.
|
inlinestatic |
Returns a random vector with unit length; all directions are equally likely.
RNG | The random-number-generator type. |
[in] | rng | The random-number-generator. |
Definition at line 367 of file Vector3D.hpp.
|
inline |
Returns this vector, but rotated about the given axis by the given angle.
[in] | axis | The axis to rotate about, which is assumed to be normalized. |
[in] | angle | The angle to rotate with. |
Definition at line 322 of file Vector3D.hpp.
|
inlinestatic |
Constructs a unit vector from the two given random variables.
[in] | X_1 | A variable drawn from the uniform distribution on the closed interval \( \left[ 0, 1 \right] \). |
[in] | X_2 | A variable drawn from the uniform distribution on either the half-open interval \( \left[ 0, 1 \right) \) or the half-open interval \( \left( 0, 1 \right] \). |
Definition at line 408 of file Vector3D.hpp.
|
inline |
Returns the x coordinate.
Definition at line 61 of file Vector3D.hpp.
|
inline |
Returns the y coordinate.
Definition at line 90 of file Vector3D.hpp.
|
inline |
Returns the z coordinate.
Definition at line 119 of file Vector3D.hpp.
|
inline |
Returns whether at least one of the components of this vector is negative.
Definition at line 332 of file Vector3D.hpp.
|
inline |
Returns whether all components are finite, i.e.
neither infinite nor NaN.
Definition at line 341 of file Vector3D.hpp.
|
inline |
Returns the magnitude of this vector.
Definition at line 236 of file Vector3D.hpp.
|
inline |
Returns the square of the magnitude of this vector.
Definition at line 218 of file Vector3D.hpp.
|
inline |
Normalizes this vector.
OpenMPCD::DivisionByZeroException | For Host code, throws if magnitude() == 0 . |
Definition at line 248 of file Vector3D.hpp.
|
inline |
Inequality operator.
[in] | rhs | The right-hand-side vector. |
Definition at line 445 of file Vector3D.hpp.
|
inline |
Scalar multiplication operator.
[in] | scale | The scaling factor. |
Definition at line 533 of file Vector3D.hpp.
|
inline |
Scalar multiplication and assignment operator.
[in] | scale | The scaling factor. |
Definition at line 519 of file Vector3D.hpp.
|
inline |
Addition operator.
[in] | rhs | The right-hand-side vector. |
Definition at line 471 of file Vector3D.hpp.
|
inline |
Addition-and-assignment operator.
[in] | rhs | The right-hand-side vector. |
Definition at line 456 of file Vector3D.hpp.
|
inline |
The negation operator.
Definition at line 508 of file Vector3D.hpp.
|
inline |
Subtraction operator.
[in] | rhs | The right-hand-side vector. |
Definition at line 498 of file Vector3D.hpp.
|
inline |
Subtraction-and-assignment operator.
[in] | rhs | The right-hand-side vector. |
Definition at line 483 of file Vector3D.hpp.
|
inline |
Scalar division operator.
DivisionByZeroExcpetion | For Host code, throws if divisor is 0. |
[in] | divisor | The divisor. |
Definition at line 578 of file Vector3D.hpp.
|
inline |
Scalar division and assignment operator.
OpenMPCD::DivisionByZeroException | For Host code, throws if divisor is 0. |
[in] | divisor | The divisor. |
Definition at line 558 of file Vector3D.hpp.
|
inline |
Less-than operator.
Compares, in this order, the x, y, and z components.
[in] | rhs | The right-hand-side instance. |
Definition at line 589 of file Vector3D.hpp.
|
inline |
Equality operator.
[in] | rhs | The right-hand-side vector. |
Definition at line 433 of file Vector3D.hpp.
|
inline |
Rotates this vector about the given axis by the given angle.
[in] | axis | The axis to rotate about, which is assumed to be normalized. |
[in] | angle | The angle to rotate with. |
Definition at line 308 of file Vector3D.hpp.
|
inline |
Sets the coordinates.
[in] | x_ | The x coordinate. |
[in] | y_ | The y coordinate. |
[in] | z_ | The z coordinate. |
Definition at line 151 of file Vector3D.hpp.
|
inline |
|
inline |
Sets the y coordinate.
[in] | val | The new value. |
Definition at line 100 of file Vector3D.hpp.
|
inline |
Sets the z coordinate.
[in] | val | The new value. |
Definition at line 129 of file Vector3D.hpp.
|
friend |
Scalar multiplication operator.
[in] | scale | The scaling factor. |
[in] | vec | The vector to multiply. |
Definition at line 545 of file Vector3D.hpp.
|
friend |
Output operator for streams.
[in] | stream | The stream to print to. |
[in] | vector | The vector to print. |
Definition at line 614 of file Vector3D.hpp.