#include <openbabel/math/vector3.h>
Public Member Functions | |
vector3 (const double inX=0.0, const double inY=0.0, const double inZ=0.0) | |
vector3 (double inV[3]) | |
vector3 (const vector3 &v) | |
~vector3 () | |
void | Set (const double inX, const double inY, const double inZ) |
void | Set (const double *c) |
void | SetX (const double inX) |
void | SetY (const double inY) |
void | SetZ (const double inZ) |
void | Get (double *c) |
double | operator[] (unsigned int i) const |
vector3 & | operator= (const vector3 &v) |
const double * | AsArray () const |
vector3 & | operator+= (const vector3 &v) |
vector3 & | operator-= (const vector3 &v) |
vector3 & | operator+= (const double *f) |
vector3 & | operator-= (const double *f) |
vector3 & | operator*= (const double &c) |
vector3 & | operator/= (const double &c) |
vector3 & | operator*= (const matrix3x3 &) |
void | randomUnitVector (OBRandom *oeRand=NULL) |
vector3 & | normalize () |
bool | CanBeNormalized () const |
double | length_2 () const |
double | length () const |
const double & | x () const |
const double & | y () const |
const double & | z () const |
double & | x () |
double & | y () |
double & | z () |
int | operator== (const vector3 &) const |
int | operator!= (const vector3 &other) const |
bool | IsApprox (const vector3 &other, const double &precision) const |
double | distSq (const vector3 &vv) const |
bool | createOrthoVector (vector3 &v) const |
The vector3 class was designed to simplify operations with floating point coordinates. To this end many of the common operations have been overloaded for simplicity. Vector addition, subtraction, scalar multiplication, dot product, cross product, magnitude and a number of other utility functions are built in to the vector class. For a full description of the class member functions please consult the documentation. The following code demonstrates several of the functions of the vector class:
vector3 | ( | const double | inX = 0.0 , |
|
const double | inY = 0.0 , |
|||
const double | inZ = 0.0 | |||
) | [inline] |
Constructor.
vector3 | ( | double | inV[3] | ) | [inline] |
~vector3 | ( | ) | [inline] |
Destructor.
void Set | ( | const double | inX, | |
const double | inY, | |||
const double | inZ | |||
) | [inline] |
Set x,y and z-component of a vector.
Referenced by OBRotamerList::AddRotamer(), OBRing::findCenterAndNormal(), OBFloatGrid::GetMidpointVector(), OBAtom::GetNewBondVector(), OBAtom::GetVector(), OBForceField::NumericalDerivative(), OBForceField::NumericalSecondDerivative(), vector3::randomUnitVector(), OBAtom::SetVector(), OBForceField::ValidateConjugateGradients(), and OBForceField::ValidateSteepestDescent().
void Set | ( | const double * | c | ) | [inline] |
Set x,y and z-component of a vector from c[0]..c[2].
void SetX | ( | const double | inX | ) | [inline] |
Access function to get the x-coordinate of the vector.
Referenced by OBForceField::GetGrid(), OBForceField::MolecularDynamicsTakeNSteps(), and vector3::operator*=().
void SetY | ( | const double | inY | ) | [inline] |
Access function to get the y-coordinate of the vector.
Referenced by OBForceField::GetGrid(), OBForceField::MolecularDynamicsTakeNSteps(), and vector3::operator*=().
void SetZ | ( | const double | inZ | ) | [inline] |
Access function to get the z-coordinate of the vector.
Referenced by OpenBabel::CalcSignedVolume(), OBForceField::GetGrid(), OBForceField::MolecularDynamicsTakeNSteps(), and vector3::operator*=().
void Get | ( | double * | c | ) | [inline] |
Set c[0]..c[2] to the components of the vector.
Referenced by OBForceField::VectorBondDerivative().
double operator[] | ( | unsigned int | i | ) | const |
Access function to x: [0], y: [1], and z[2].
This (slow) method allows to access the elements of the vector as if it were an array of doubles. If the index is > 2, then a warning is printed and 0.0 is returned. Otherwise, if i is 0, 1 or 2, then a reference to x, y or z is returned, respectively.
const double* AsArray | ( | ) | const [inline] |
Vector addition (add v
to *this).
Vector subtraction (subtract v
from *this).
vector3& operator+= | ( | const double * | f | ) | [inline] |
Scalar addition (add f
to *this).
vector3& operator-= | ( | const double * | f | ) | [inline] |
Scalar subtraction (subtract f
from *this).
vector3& operator*= | ( | const double & | c | ) | [inline] |
Scalar multiplication (multiply *this by c
).
vector3& operator/= | ( | const double & | c | ) | [inline] |
Scalar division (divide *this by c
).
Multiplication of matrix and vector
void randomUnitVector | ( | OBRandom * | obRandP = NULL |
) |
Create a random unit vector.
Replaces *this with a random unit vector, which is (supposed to be) uniformly distributed over the unit sphere. Uses the random number generator obRand, or uses the system number generator with a time seed if obRand == NULL.
obRandP | random number generator to use, or NULL, if the system random number generator (with time seed) should be used |
Referenced by OBAtom::GetNewBondVector(), matrix3x3::randomRotation(), OBForceField::VectorBondDerivative(), and OBForceField::VectorLengthDerivative().
vector3 & normalize | ( | ) |
Scales a vector to give it length one.
Referenced by OBRing::findCenterAndNormal(), OBBuilder::GetNewBondVector(), OBAtom::GetNewBondVector(), OpenBabel::InternalToCartesian(), OBForceField::LineSearch(), matrix3x3::PlaneReflection(), vector3::randomUnitVector(), matrix3x3::RotAboutAxisByAngle(), OBAtom::SetHybAndGeom(), OBBond::SetLength(), OBForceField::ValidateLineSearch(), and OBForceField::VectorAngleDerivative().
bool CanBeNormalized | ( | ) | const |
Referenced by vector3::createOrthoVector(), and vector3::normalize().
double length_2 | ( | ) | const [inline] |
Referenced by OpenBabel::CartesianToInternal(), OBAtom::GetNewBondVector(), vector3::IsApprox(), and vector3::randomUnitVector().
double length | ( | ) | const [inline] |
Referenced by OpenBabel::CalcTorsionAngle(), OpenBabel::CartesianToInternal(), OBAtom::GetAngle(), OBUnitCell::GetCellMatrix(), OBUnitCell::GetCellVectors(), OBAtom::GetNewBondVector(), OBForceField::LineSearch(), vector3::normalize(), OpenBabel::Point2Plane(), OBUnitCell::SetData(), OpenBabel::vectorAngle(), OBForceField::VectorAngleDerivative(), OBForceField::VectorLengthDerivative(), OBForceField::VectorOOPDerivative(), and OBForceField::VectorTorsionDerivative().
const double& x | ( | ) | const [inline] |
Access function to get the x-coordinate of the vector.
Referenced by OBMol::AddHydrogens(), SpaceGroup::AddTransform(), OBForceField::ConjugateGradientsInitialize(), OBForceField::ConjugateGradientsTakeNSteps(), OBBuilder::Connect(), OpenBabel::cross(), vector3::distSq(), OpenBabel::dot(), OBGridData::GetAxes(), OBForceField::GetGrid(), OBAtom::GetNewBondVector(), OBGridData::GetValue(), matrix3x3::matrix3x3(), OBForceField::MolecularDynamicsTakeNSteps(), transform3d::Normalize(), OBForceField::NumericalDerivative(), OBForceField::NumericalSecondDerivative(), OpenBabel::operator*(), vector3::operator*=(), OpenBabel::operator+(), OpenBabel::operator-(), OpenBabel::operator/(), OpenBabel::operator<<(), vector3::operator==(), matrix3x3::PlaneReflection(), OBGrid::PointIsInBox(), matrix3x3::RotAboutAxisByAngle(), matrix3x3::SetColumn(), OBFloatGrid::SetLimits(), matrix3x3::SetRow(), OBAtom::SetVector(), OBForceField::SteepestDescentTakeNSteps(), SpaceGroup::Transform(), OBMol::Translate(), OBForceField::ValidateConjugateGradients(), OBForceField::ValidateGradientError(), and OBForceField::ValidateSteepestDescent().
const double& y | ( | ) | const [inline] |
Access function to get the y-coordinate of the vector.
Referenced by OBMol::AddHydrogens(), SpaceGroup::AddTransform(), OBForceField::ConjugateGradientsInitialize(), OBForceField::ConjugateGradientsTakeNSteps(), OBBuilder::Connect(), OpenBabel::cross(), vector3::distSq(), OpenBabel::dot(), OBGridData::GetAxes(), OBForceField::GetGrid(), OBAtom::GetNewBondVector(), OBGridData::GetValue(), matrix3x3::matrix3x3(), OBForceField::MolecularDynamicsTakeNSteps(), transform3d::Normalize(), OBForceField::NumericalDerivative(), OBForceField::NumericalSecondDerivative(), OpenBabel::operator*(), vector3::operator*=(), OpenBabel::operator+(), OpenBabel::operator-(), OpenBabel::operator/(), OpenBabel::operator<<(), vector3::operator==(), matrix3x3::PlaneReflection(), OBGrid::PointIsInBox(), matrix3x3::RotAboutAxisByAngle(), matrix3x3::SetColumn(), OBFloatGrid::SetLimits(), matrix3x3::SetRow(), OBAtom::SetVector(), OBForceField::SteepestDescentTakeNSteps(), SpaceGroup::Transform(), OBMol::Translate(), OBForceField::ValidateConjugateGradients(), OBForceField::ValidateGradientError(), and OBForceField::ValidateSteepestDescent().
const double& z | ( | ) | const [inline] |
Access function to get the z-coordinate of the vector.
Referenced by OBMol::AddHydrogens(), SpaceGroup::AddTransform(), OBForceField::ConjugateGradientsInitialize(), OBForceField::ConjugateGradientsTakeNSteps(), OBBuilder::Connect(), OBMol::ConnectTheDots(), OpenBabel::cross(), vector3::distSq(), OpenBabel::dot(), OBGridData::GetAxes(), OBForceField::GetGrid(), OBAtom::GetNewBondVector(), OBGridData::GetValue(), matrix3x3::matrix3x3(), OBForceField::MolecularDynamicsTakeNSteps(), transform3d::Normalize(), OBForceField::NumericalDerivative(), OBForceField::NumericalSecondDerivative(), OpenBabel::operator*(), vector3::operator*=(), OpenBabel::operator+(), OpenBabel::operator-(), OpenBabel::operator/(), OpenBabel::operator<<(), vector3::operator==(), matrix3x3::PlaneReflection(), OBGrid::PointIsInBox(), matrix3x3::RotAboutAxisByAngle(), matrix3x3::SetColumn(), OBFloatGrid::SetLimits(), matrix3x3::SetRow(), OBAtom::SetVector(), OBForceField::SteepestDescentTakeNSteps(), SpaceGroup::Transform(), OBMol::Translate(), OBForceField::ValidateConjugateGradients(), and OBForceField::ValidateGradientError().
double& x | ( | ) | [inline] |
Access function to set the x-coordinate of the vector.
double& y | ( | ) | [inline] |
Access function to set the y-coordinate of the vector.
double& z | ( | ) | [inline] |
Access function to set the z-coordinate of the vector.
int operator== | ( | const vector3 & | other | ) | const |
Comparison Methods.
Equivalence of vectors
int operator!= | ( | const vector3 & | other | ) | const [inline] |
bool IsApprox | ( | const vector3 & | other, | |
const double & | precision | |||
) | const |
Safe comparison for floating-point vector3.
other
, to the precision precision
. More specifically, this method works exactly like the OpenBabel::IsApprox() function, replacing the absolute value for doubles by the norm for vectors. other | The vector for comparison | |
precision | This parameter plays the same role as in OpenBabel::IsApprox(). |
Referenced by OBAtom::GetNewBondVector().
double distSq | ( | const vector3 & | vv | ) | const [inline] |
}@
Referenced by OBForceField::GetGrid(), and vector3::IsApprox().
bool createOrthoVector | ( | vector3 & | res | ) | const |
Construct a unit vector orthogonal to *this.
Creates a vector of length one, orthogonal to *this.
res | reference by which to pass the result. |