BTK::MATH Namespace Reference


Classes

class  BTKMatrix
class  BTKVector
static const double PI = 3.1415926535897323
 MathConst Mathematical Constants.
static const double RADIANS_PER_DEGREE = PI/180.0
 MathConst Mathematical Constants.
static const double DEGREES_PER_RADIAN = 180.0/PI
 MathConst Mathematical Constants.
static const double DOUBLE_EPSILON (std::numeric_limits< double >::epsilon())
 Smallest double-precision value e, where x + e != x.
static const float FLOAT_EPSILON (std::numeric_limits< float >::epsilon())
 MathConst Mathematical Constants.

Typedefs

Vector and Matrix types.
The BTK* types are typedefs to appropriate classes in the Boost::ublas linear algebra library.

Using these types in the BTK makes it easier to write/read linear algebra code, and easier to switch the code to other linear algebra systems (should that ever become necessary).

typedef uBLAS::symmetric_matrix<
double > 
BTKSymmetricMatrix

Functions

template<typename T>
square (T val)
 Square a value.
template<typename T>
cube (T val)
 Cube a value.
template<typename T>
bool equivalent (T x, T y, T precision)
template<typename T>
bool equivalent (T x, T y)
template<>
bool equivalent (float x, float y)
template<>
bool equivalent (double x, double y)
double deg2rad (double angle_in_degrees)
double rad2deg (double angle_in_radians)
double point_dihedral (BTKVector const &a, BTKVector const &b, BTKVector const &c, BTKVector const &d)
 Calculate the dihedral angle between the planes a-b-c and d-c-b.
bool within_sqr_dist (BTKVector const &a, BTKVector const &b, double r_squared)
 See if two vectors are within a squared distance threshold of one another.
BTKVector set_vector_from_dihedral (BTKVector const &v3, BTKVector const &v2, BTKVector const &v1, double len34, double ang234, double dih1234)
 calculate vector position from a dihedral angle
BTKVector set_vector_from_two_angles (BTKVector const &v3, BTKVector const &v2, BTKVector const &v1, double len34, double ang234, double ang134)
 Calculate vector position from two vector angles.
double point_angle (BTKVector const &v1, BTKVector const &v2, BTKVector const &v3)
 calculate the angle formed by v1-v2 amd v3-v2
void initialize_rotation_matrix (BTKVector const &axis, double theta, BTKMatrix &rm)
 Initialize a pre-existing rotation matrix for rotation about an axis.
void initialize_rotation_matrix (double phi, double theta, double psi, BTKMatrix &rm)
 Initialize a pre-existing rotation matrix using Euler angles.
BTKMatrix create_rotation_matrix (BTKVector const &axis, double theta)
 Create a rotation matrix for a rotation about an axis.
BTKMatrix create_rotation_matrix (double phi, double theta, double psi)
 Create a new rotation matrix using Euler angles.
BTKVector project_normal (BTKVector const &a, BTKVector const &b)
 Project the component of vector a that is normal to vector b.
BTKVector project (BTKVector const &a, BTKVector const &b)
 Project vector a onto vector b.
double vector_dihedral (BTKVector const &v1, BTKVector const &v2, BTKVector const &v3)
 Calculate the dihedral angle formed by three vectors.
BTKVectornormalize (BTKVector &v)
 Normalize a vector to unit length.
double length (BTKVector const &v)
 Get the length of a vector (aka, the l2 norm or euclidean norm).
BTKVector cross (BTKVector const &lhs, BTKVector const &rhs)
 Compute the cross product of two 3D vectors.
double cosine_vector_angle (BTKVector const &v1, BTKVector const &v2)
 Calculate the cosine of the angle between two vectors.
double vector_angle (BTKVector const &v1, BTKVector const &v2)
 Calculate the angle between two vectors.


Typedef Documentation

typedef uBLAS::symmetric_matrix<double> BTKSymmetricMatrix


Function Documentation

double BTK::MATH::cosine_vector_angle ( BTKVector const &  v1,
BTKVector const &  v2 
)

Calculate the cosine of the angle between two vectors.

BTKVector BTK::MATH::cross ( BTKVector const &  lhs,
BTKVector const &  rhs 
)

Compute the cross product of two 3D vectors.

T BTK::MATH::cube ( val  ) 

Cube a value.

double BTK::MATH::deg2rad ( double  angle_in_degrees  ) 

static const double BTK::MATH::DOUBLE_EPSILON ( std::numeric_limits< double >::  epsilon()  )  [static]

Smallest double-precision value e, where x + e != x.

bool BTK::MATH::equivalent ( double  x,
double  y 
)

bool BTK::MATH::equivalent ( float  x,
float  y 
)

bool BTK::MATH::equivalent ( x,
y 
)

bool BTK::MATH::equivalent ( x,
y,
precision 
)

static const float BTK::MATH::FLOAT_EPSILON ( std::numeric_limits< float >::  epsilon()  )  [static]

MathConst Mathematical Constants.

double BTK::MATH::length ( BTKVector const &  v  ) 

Get the length of a vector (aka, the l2 norm or euclidean norm).

Warning: if you're calling this function from a multi-calculation expression, you might want to directly call uBLAS::norm_2() instead, for efficiency reasons.

Examples:
gyration_radius.cpp.

BTKVector& BTK::MATH::normalize ( BTKVector &  v  ) 

Normalize a vector to unit length.

This function normalizes the input vector.

double BTK::MATH::point_angle ( BTKVector const &  v1,
BTKVector const &  v2,
BTKVector const &  v3 
)

calculate the angle formed by v1-v2 amd v3-v2

double point_dihedral ( BTKVector const &  a,
BTKVector const &  b,
BTKVector const &  c,
BTKVector const &  d 
)

Calculate the dihedral angle between the planes a-b-c and d-c-b.

This offers a more conventional "four point" access to the dihedral function.

BTKVector project ( BTKVector const &  a,
BTKVector const &  b 
)

Project vector a onto vector b.

Get the component of vector a that is parallel to vector b.

BTKVector project_normal ( BTKVector const &  a,
BTKVector const &  b 
)

Project the component of vector a that is normal to vector b.

Get the component of a that is perpendicular to b.

double BTK::MATH::rad2deg ( double  angle_in_radians  ) 

BTKVector set_vector_from_dihedral ( BTKVector const &  v3,
BTKVector const &  v2,
BTKVector const &  v1,
double  len34,
double  ang234,
double  dih1234 
)

calculate vector position from a dihedral angle

Calculates the position of a vector from 3 other atoms that define a a dihedral angle with the build vector

Parameters:
len34 distance between v3 and v4
ang234 angle formed by v2 - v3 and v4 - v3
dih1234 dihedral angle between v4 - v3 and v1 - v2 along the axis formed by v3 - v2
Returns:
v4, the vector built from vectors v1,v2 and v3

BTKVector set_vector_from_two_angles ( BTKVector const &  v3,
BTKVector const &  v2,
BTKVector const &  v1,
double  len34,
double  ang234,
double  ang134 
)

Calculate vector position from two vector angles.

Calculates the position of a point, v4, using three other points, v1,v2,v3, given two vector angles (angle(v4-v3,v2-v3) & angle(v4-v3,v1-v3)), and a vector length ( |v4-v3| ), assuming a right-handed relationship between v1-v3,v2-v3 and v4-v3 (see below)

Submit the vectors in order such that the three vectors v1-v3, v2-v3 and v4-v3, form a right-handed system, ie. so that dot(v4-v3,cross(v1-v3,v2-v3)) is a positive number, if you have a left-handed arrangment, then swap the arguments v2 and v1 (and the corresponding angle arguments ang234 and ang134 )

Parameters:
len34 | v4-v3 |
ang234 vector angle between v2-v3 and v4-v3
ang134 vector angle between v1-v3 and v4-v3

T BTK::MATH::square ( val  ) 

Square a value.

double BTK::MATH::vector_angle ( BTKVector const &  v1,
BTKVector const &  v2 
)

Calculate the angle between two vectors.

double vector_dihedral ( BTKVector const &  v1,
BTKVector const &  v2,
BTKVector const &  v3 
)

Calculate the dihedral angle formed by three vectors.

The dihedral angle is the angle formed between v1 and v3, about vector v2.

bool within_sqr_dist ( BTKVector const &  a,
BTKVector const &  b,
double  r_squared 
)

See if two vectors are within a squared distance threshold of one another.

Parameters:
a BTKVector 1
b BTKVector 2
r_squared Squared distance threshold.
Returns:
true if vector 1 and 2 are within sqrt(r_squared) units of one another.


Variable Documentation

const double DEGREES_PER_RADIAN = 180.0/PI [static]

MathConst Mathematical Constants.

const double PI = 3.1415926535897323 [static]

MathConst Mathematical Constants.

const double RADIANS_PER_DEGREE = PI/180.0 [static]

MathConst Mathematical Constants.


Generated on Sun Jul 15 20:46:37 2007 for BTK Core by  doxygen 1.5.1