Open Babel
3.0
|
#include <openbabel/math/vector3.h>
Public Types | |
typedef double * | iterator |
typedef const double * | const_iterator |
typedef std::ptrdiff_t | difference_type |
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 () | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
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) |
double | GetX () const |
double | GetY () const |
double | GetZ () const |
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 () |
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 |
Represents a vector in 3-dimensional real space.
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:
typedef double* iterator |
A random access iterator over x, y, z.
typedef const double* const_iterator |
A random access iterator over const x, y, z.
typedef std::ptrdiff_t difference_type |
A signed integral type for differences between two iterators.
|
inline |
Constructor.
|
inline |
|
inline |
Destructor.
|
inline |
|
inline |
|
inline |
/return const_iterator to beginning
|
inline |
/return const_iterator to end
|
inline |
Set x,y and z-component of a vector.
Referenced by OBRotamerList::AddRotamer(), OBRing::findCenterAndNormal(), OBFloatGrid::GetMidpointVector(), OBBuilder::GetNewBondVector(), OBAtom::GetVector(), OBForceField::NumericalDerivative(), OBForceField::NumericalSecondDerivative(), OBForceField::ValidateConjugateGradients(), and OBForceField::ValidateSteepestDescent().
|
inline |
Set x,y and z-component of a vector from c[0]..c[2].
|
inline |
Access function to set the x-coordinate of the vector.
Referenced by OpenBabel::areDuplicateAtoms(), OBForceField::GetGrid(), OBForceField::MolecularDynamicsTakeNSteps(), and vector3::operator*=().
|
inline |
Access function to set the y-coordinate of the vector.
Referenced by OpenBabel::areDuplicateAtoms(), OBForceField::GetGrid(), OBForceField::MolecularDynamicsTakeNSteps(), and vector3::operator*=().
|
inline |
Access function to set the z-coordinate of the vector.
Referenced by OpenBabel::areDuplicateAtoms(), OBForceField::GetGrid(), OBForceField::MolecularDynamicsTakeNSteps(), and vector3::operator*=().
|
inline |
Access function to get the x-coordinate of the vector.
|
inline |
Access function to get the y-coordinate of the vector.
|
inline |
Access function to get the z-coordinate of the vector.
|
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 one 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.
|
inline |
Vector subtraction (subtract v
from *this)
|
inline |
Scalar addition (add f
to *this)
|
inline |
Scalar subtraction (subtract f
from *this)
|
inline |
Scalar multiplication (multiply *this by c
)
|
inline |
Scalar division (divide *this by c
)
Multiplication of matrix and vector
calculates the product m*(*this) of the matrix m and the column vector represented by *this
void randomUnitVector | ( | ) |
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 system number generator with a time seed.
Referenced by OBBuilder::Build(), OBBuilder::Connect(), OBBuilder::GetNewBondVector(), OBBond::SetLength(), OBForceField::VectorBondDerivative(), and OBForceField::VectorLengthDerivative().
vector3 & normalize | ( | ) |
Scales a vector to give it length one.
This method normalizes *this. In other words, it divides the x,y,z coords of *this by this->length(). If *this can't be safely normalized, it remains unchanged. See CanBeNormalized().
Referenced by OBBuilder::Build(), OBDepict::DrawMolecule(), OBRing::findCenterAndNormal(), OBBuilder::GetNewBondVector(), OpenBabel::InternalToCartesian(), OBBuilder::IsSpiroAtom(), OBForceField::LineSearch(), matrix3x3::PlaneReflection(), matrix3x3::RotAboutAxisByAngle(), OBAtom::SetHybAndGeom(), OBBond::SetLength(), OBForceField::ValidateLineSearch(), and OBForceField::VectorAngleDerivative().
bool CanBeNormalized | ( | ) | const |
This method returns true if *this can be safely normalized. Vectors that can't be safely normalized are:
|
inline |
Referenced by OpenBabel::areDuplicateAtoms(), OpenBabel::CartesianToInternal(), OBForceField::ConjugateGradientsTakeNSteps(), vector3::IsApprox(), OBBond::SetLength(), and OBForceField::SteepestDescentTakeNSteps().
|
inline |
Referenced by OpenBabel::CalcTorsionAngle(), OpenBabel::CartesianToInternal(), OBBuilder::Connect(), OBUnitCell::GetA(), OBAtom::GetAngle(), OBUnitCell::GetB(), OBUnitCell::GetC(), OBForceField::LineSearch(), OpenBabel::Point2Line(), OpenBabel::Point2PlaneSigned(), OBUnitCell::SetData(), OBBuilder::Swap(), OpenBabel::vectorAngle(), OBForceField::VectorAngleDerivative(), OBForceField::VectorLengthDerivative(), OBForceField::VectorOOPDerivative(), and OBForceField::VectorTorsionDerivative().
|
inline |
Access function to get the x-coordinate of the vector.
Referenced by OBMol::AddHydrogens(), OBMol::AddNewHydrogens(), SpaceGroup::AddTransform(), OpenBabel::areDuplicateAtoms(), OBBuilder::Build(), OBForceField::ConjugateGradientsInitialize(), OBForceField::ConjugateGradientsTakeNSteps(), OBBuilder::Connect(), OpenBabel::cross(), transform3d::DescribeAsValues(), vector3::distSq(), OpenBabel::dot(), OBDepict::DrawMolecule(), OBUnitCell::FillUnitCell(), OBGridData::GetAxes(), OBForceField::GetGrid(), OpenBabel::GetLabelAlignment(), OBBuilder::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(), OpenBabel::UpdateConformersFromTree(), OBForceField::ValidateConjugateGradients(), OBForceField::ValidateGradientError(), OBForceField::ValidateSteepestDescent(), OBUnitCell::WrapFractionalCoordinate(), and OBAtom::x().
|
inline |
Access function to get the y-coordinate of the vector.
Referenced by OBMol::AddHydrogens(), OBMol::AddNewHydrogens(), SpaceGroup::AddTransform(), OpenBabel::areDuplicateAtoms(), OBBuilder::Build(), OBForceField::ConjugateGradientsInitialize(), OBForceField::ConjugateGradientsTakeNSteps(), OBBuilder::Connect(), OpenBabel::cross(), vector3::distSq(), OpenBabel::dot(), OBDepict::DrawMolecule(), OBUnitCell::FillUnitCell(), OBGridData::GetAxes(), OBForceField::GetGrid(), OpenBabel::GetLabelAlignment(), OBBuilder::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(), OpenBabel::UpdateConformersFromTree(), OBForceField::ValidateConjugateGradients(), OBForceField::ValidateGradientError(), OBForceField::ValidateSteepestDescent(), OBUnitCell::WrapFractionalCoordinate(), and OBAtom::y().
|
inline |
Access function to get the z-coordinate of the vector.
Referenced by OBMol::AddHydrogens(), OBMol::AddNewHydrogens(), SpaceGroup::AddTransform(), OpenBabel::areDuplicateAtoms(), OBBuilder::Build(), OBForceField::ConjugateGradientsInitialize(), OBForceField::ConjugateGradientsTakeNSteps(), OBBuilder::Connect(), OBMol::ConnectTheDots(), OpenBabel::cross(), vector3::distSq(), OpenBabel::dot(), OBDepict::DrawMolecule(), OBUnitCell::FillUnitCell(), OBGridData::GetAxes(), OBForceField::GetGrid(), OBBuilder::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(), OpenBabel::UpdateConformersFromTree(), OBForceField::ValidateConjugateGradients(), OBForceField::ValidateGradientError(), OBUnitCell::WrapFractionalCoordinate(), and OBAtom::z().
|
inline |
Access function to set the x-coordinate of the vector.
|
inline |
Access function to set the y-coordinate of the vector.
|
inline |
Access function to set the z-coordinate of the vector.
int operator== | ( | const vector3 & | other | ) | const |
Comparison Methods.
Equivalence of vectors
|
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(). |
|
inline |
}@
equivalent to length_2(*this-vv)
Referenced by OBDepict::DrawMolecule(), and OBForceField::GetGrid().
bool createOrthoVector | ( | vector3 & | res | ) | const |
Construct a unit vector orthogonal to *this.
Creates a vector of length one, orthogonal to *this.
It requires that *this is normalizable; otherwise it just returns false. See CanBeNormalized()
res | reference by which to pass the result. |