Loading...
Searching...
No Matches
SBDTypePhysicalVector3< Quantity > Class Template Reference

This template class is used to represent three-dimensional physical vectors. More...

Useful functions

static const SBDTypePhysicalVector3< Quantity > one
 The one physical vector, with all components equal to one.
 
static const SBDTypePhysicalVector3< Quantity > zero
 The zero physical vector.
 
Quantity v [3]
 The components of the physical vector.
 
void setOne ()
 Sets all components to one.
 
void setZero ()
 Sets all components to zero.
 
Quantity norm () const
 Returns the norm of this physical vector.
 
SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename Quantity::UnitType >::UnitType > norm2 () const
 Returns the squared norm of this physical vector.
 
void print () const
 Prints this physical vector.
 
SBDTypePhysicalVector3< SBQuantity::dimensionlessnormalizedVersion () const
 Returns the normalized version of this physical vector.
 
SBDTypePhysicalVector3< Quantity > normalizedVersionWithUnits () const
 Returns the normalized version of this physical vector, but with preserved units.
 
void normalizeWithUnits ()
 Normalizes this physical vector while preserving units.
 
void normalize ()
 Normalizes this dimensionless physical vector.
 
template<typename QuantityLower , typename QuantityUpper >
void updateMinMax (SBDTypePhysicalVector3< QuantityLower > &lower, SBDTypePhysicalVector3< QuantityUpper > &upper) const
 Updates the lower and upper vector bounds with this physical vector.
 
void swap (unsigned int i, unsigned j)
 Swaps components i and j of this physical vector.
 
static SBDTypePhysicalVector3< Quantity > fromLinearInterpolation (const SBDTypePhysicalVector3< Quantity > &u0, const SBDTypePhysicalVector3< Quantity > &u1, double alpha)
 Returns a linear interpolation between two vectors v0 and v1 for a parameter alpha in the closed unit interval [0, 1].
 
static SBDTypePhysicalVector3< Quantity > fromLineProjection (const SBDTypePhysicalVector3< Quantity > &x, const SBDTypePhysicalVector3< Quantity > &a, const SBDTypePhysicalVector3< Quantity > &b, const typename SBQuantityPower< 2, Quantity >::Type &threshold=typename SBQuantityPower< 2, Quantity >::Type(1e-10))
 Returns the projection of x on the line passing through a and b. If the squared distance between a and b is below the threshold, then x is returned.
 
static SBDTypePhysicalVector3< Quantity > fromLineSegmentProjection (const SBDTypePhysicalVector3< Quantity > &x, const SBDTypePhysicalVector3< Quantity > &a, const SBDTypePhysicalVector3< Quantity > &b, const typename SBQuantityPower< 2, Quantity >::Type &threshold=typename SBQuantityPower< 2, Quantity >::Type(1e-10))
 Returns the projection of x on the line segment ab. If the squared distance between a and b is below the threshold, then x is returned.
 
static SBDTypePhysicalVector3< Quantity > fromPlaneProjection (const SBDTypePhysicalVector3< Quantity > &x, const SBDTypePhysicalVector3< Quantity > &a, const SBDTypePhysicalVector3< SBQuantity::dimensionless > &n)
 Returns the projection of x on the plane passing through a with normal n. The normal
is assumed to be normalized.
 
static SBDTypePhysicalVector3< Quantity > fromPlaneProjection (const SBDTypePhysicalVector3< Quantity > &x, const SBDTypePhysicalVector3< Quantity > &a, const SBDTypePhysicalVector3< Quantity > &b, const SBDTypePhysicalVector3< Quantity > &c, const typename SBQuantityPower< 2, Quantity >::Type &threshold=typename SBQuantityPower< 2, Quantity >::Type(1e-10))
 Returns the projection of x on the plane passing through a, b and c. If the length of (c - a) ^ (b - a) is smaller than threshold, then x is returned.
 
static SBQuantity::radian computeAngle (const SBDTypePhysicalVector3< Quantity > &a, const SBDTypePhysicalVector3< Quantity > &b)
 Returns the angle in radians between the vector a and the vector b.
 
static SBQuantity::radian computeDihedralAngle (const SBDTypePhysicalVector3< SBQuantity::position > &a, const SBDTypePhysicalVector3< SBQuantity::position > &b, const SBDTypePhysicalVector3< SBQuantity::position > &c, const SBDTypePhysicalVector3< SBQuantity::position > &d)
 Returns the dihedral angle in radians based on the four given positions a, b, c, d, where positions b and c form the main axis.
 
static void sampledUnitSphere3 (SBVector< SBDTypePhysicalVector3< SBQuantity::dimensionless > > &sampleVector, const unsigned int numberOfPoints)
 Populates the sampleVector vector with evenly distributed numberOfPoints points on a unit 3D sphere. The points on a unit 3D sphere are generated using the golden section spiral algorithm.
 

Constructors

 SBDTypePhysicalVector3 ()
 Constructs the physical vector [ 0 0 0 ].
 
 SBDTypePhysicalVector3 (const Quantity &x)
 Constructs the physical vector [ x x x ].
 
 SBDTypePhysicalVector3 (const Quantity &x, const Quantity &y, const Quantity &z)
 Constructs the physical vector [ x y z ].
 
 SBDTypePhysicalVector3 (Quantity u[3])
 Constructs the physical vector [ v[0] v[1] v[2] ].
 
 SBDTypePhysicalVector3 (double x)
 Constructs a dimensionless physical vector with all components set to x.
 
 SBDTypePhysicalVector3 (double x, double y, double z)
 Constructs the dimensionless physical vector [ x y z ].
 
 SBDTypePhysicalVector3 (double u[3])
 Constructs the dimensionless physical vector [ v[0] v[1] v[2] ].
 
 SBDTypePhysicalVector3 (const SBDTypePhysicalVector3< Quantity > &u)
 Copy constructor.
 

Serialization

void serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) const
 Serializes the physical vector using the provided serializer.
 
void unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER)
 Unserializes the physical vector using the provided serializer.
 

Accessors

SBDTypePhysicalVector3< SBQuantity::dimensionlessgetValue () const
 Returns a dimensionless physical vector whose components are equal to those of this physical vector.
 
void getValue (double *array) const
 Stores the components as doubles in array[0], array[1] and array[2].
 
void getValue (float *array) const
 Stores the components as floats in array[0], array[1] and array[2].
 
void setValue (const SBDTypePhysicalVector3< SBQuantity::dimensionless > &u)
 Sets the components of this physical vector equal to those of the dimensionless physical vector u.
 

Operators

template<typename QuantityB >
SBQuantityProduct2< Quantity, QuantityB >::Type operator| (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns the dot product of this physical vector with physical vector u.
 
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > operator^ (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns the cross product of this physical vector with physical vector u.
 
SBDTypePhysicalVector3< Quantity > operator+ (const SBDTypePhysicalVector3< Quantity > &u) const
 Returns the sum of this physical vector with physical vector u.
 
SBDTypePhysicalVector3< Quantity > operator- (const SBDTypePhysicalVector3< Quantity > &u) const
 Returns the difference of this physical vector with physical vector u.
 
SBDTypePhysicalVector3< Quantity > operator* (double d) const
 Returns the product of this physical vector with double d.
 
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > operator* (QuantityB d) const
 Returns the product of this physical vector with physical quantity d.
 
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > operator* (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns the component-wise product of this physical vector with physical vector u.
 
template<typename QuantityB >
SBDTypePhysicalVector3< Quantity > & operator*= (QuantityB d)
 Multiplies this physical vector with quantity d.
 
SBDTypePhysicalVector3< Quantity > operator/ (double d) const
 Returns the division of this physical vector by double d.
 
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > operator/ (QuantityB d) const
 Returns the division of this physical vector by physical quantity d.
 
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > operator/ (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns the component-wise division of this physical vector by physical vector u.
 
template<typename QuantityB >
SBDTypePhysicalVector3< Quantity > & operator/= (QuantityB d)
 Divides this physical vector by physical quantity d.
 
SBDTypePhysicalVector3< Quantity > & operator= (const SBDTypePhysicalVector3< Quantity > &u)
 Copy assignment.
 
SBDTypePhysicalVector3< Quantity > operator- () const
 Returns the opposite of this physical vector.
 
SBDTypePhysicalVector3< Quantity > & operator+= (const SBDTypePhysicalVector3< Quantity > &u)
 Adds physical vector u to this physical vector.
 
SBDTypePhysicalVector3< Quantity > & operator-= (const SBDTypePhysicalVector3< Quantity > &u)
 Subtracts physical vector u from this physical vector.
 
template<typename QuantityB >
 operator SBDTypePhysicalVector3< QuantityB > () const
 Converts this physical vector to a physical vector with units QuantityB.
 
template<typename QuantityB >
bool operator== (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns true if this physical vector is equal to physical vector u (component-wise)
 
template<typename QuantityB >
bool operator!= (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns true if this physical vector is different from physical vector u (component-wise)
 
template<typename QuantityB >
bool operator< (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns true if this physical vector is smaller than physical vector u (lexicographic comparison)
 
template<typename QuantityB >
bool operator> (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns true if this physical vector is larger than physical vector u (lexicographic comparison)
 
template<typename QuantityB >
bool operator<= (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns true if this physical vector is smaller or equal than physical vector u (lexicographic comparison)
 
template<typename QuantityB >
bool operator>= (const SBDTypePhysicalVector3< QuantityB > &u) const
 Returns true if this physical vector is larger or equal than physical vector u (lexicographic comparison)
 
Quantity & operator[] (int index)
 Returns a reference to component index.
 
const Quantity & operator[] (int index) const
 Returns a reference to component index (const version)
 

Detailed Description

template<typename Quantity>
class SBDTypePhysicalVector3< Quantity >
Template Parameters
QuantityThe quantity type of the physical vector

This template class represents three-dimensional physical vectors, i.e. vectors whose components are physical quantities, and thus use SAMSON's unit system. In a physical vector (e.g. a position vector or a force vector), the three components have the same unit, and the SBDTypePhysicalVector3 template class is parameterized by only one type: Quantity.

Most of the time, developers of SAMSON Extensions do not have to use this template, but may directly use some predefined types, e.g. SBVector3 (dimensionless three-dimensional vector), SBPosition3 (three-dimensional vectors with length dimensions), etc.

For example, if atomPointer is a pointer to an atom, then the atom's position is a SBPosition3 physical vector:

// translate the atom by 1.0 angstrom in the x direction
SBPosition3 p = atomPointer->getPosition();
p.v[0] += SBQuantity::angstrom(1.0);
atomPointer->setPosition(p);
SBDQuantityType< SBDQuantityUnitType< SBUnitSystemSI, -10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 > > angstrom
The angstrom type.
Definition: SBDQuantity.hpp:81
Quantity v[3]
The components of the physical vector.
Definition: SBDTypePhysicalVector3.hpp:768

Short name: SBPhysicalVector3

See also
SAMSON's unit system

Member Function Documentation

◆ operator*()

template<typename Quantity >
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > SBDTypePhysicalVector3< Quantity >::operator* ( const SBDTypePhysicalVector3< QuantityB > &  u) const
inline

This operator returns the component-wise product of this physical vector with physical vector u, i.e. a physical vector in which each component is the product of the corresponding components in this physical vector and physical vector u.

◆ operator*=()

template<typename Quantity >
template<typename QuantityB >
SBDTypePhysicalVector3< Quantity > & SBDTypePhysicalVector3< Quantity >::operator*= ( QuantityB  d)
inline
Parameters
dA dimensionless physical quantity or a numeric type (i.e. int, float, double, etc)

◆ operator/()

template<typename Quantity >
template<typename QuantityB >
SBDTypePhysicalVector3< SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > SBDTypePhysicalVector3< Quantity >::operator/ ( const SBDTypePhysicalVector3< QuantityB > &  u) const
inline

This operator returns the component-wise division of this physical vector by physical vector u, i.e. a physical vector in which each component is the division of the corresponding components in this physical vector and physical vector u.

◆ operator/=()

template<typename Quantity >
template<typename QuantityB >
SBDTypePhysicalVector3< Quantity > & SBDTypePhysicalVector3< Quantity >::operator/= ( QuantityB  d)
inline
Parameters
dA dimensionless physical quantity or a numeric type (i.e. int, float, double, etc)

◆ sampledUnitSphere3()

template<typename Quantity >
static void SBDTypePhysicalVector3< Quantity >::sampledUnitSphere3 ( SBVector< SBDTypePhysicalVector3< SBQuantity::dimensionless > > &  sampleVector,
const unsigned int  numberOfPoints 
)
inlinestatic

◆ updateMinMax()

template<typename Quantity >
template<typename QuantityLower , typename QuantityUpper >
void SBDTypePhysicalVector3< Quantity >::updateMinMax ( SBDTypePhysicalVector3< QuantityLower > &  lower,
SBDTypePhysicalVector3< QuantityUpper > &  upper 
) const
inline
Parameters
lowerThe lower bound
upperThe upper bound

If necessary, this function updates the lower and upper bounds to ensure that they contain this physical vector.