API reference for geometry submodule#

Module for geometric operations.

buildh.geometry.apply_rotation(vec_to_rotate, rotation_axis, rad_angle)#

Rotate a vector around an axis by a given angle.

Note

The rotation axis is a vector of 3 elements.

Parameters
  • vec_to_rotate (numpy 1D-array) –

  • rotation_axis (numpy 1D-array) –

  • rad_angle (float) –

Returns

The final rotated (normalized) vector.

Return type

numpy 1D-array

buildh.geometry.calc_OP(C, H)#

Return the Order Parameter of a CH bond (OP).

OP is calculated according to equation:

\[S = 1/2 * (3*cos(theta)^2 -1)\]

theta is the angle between CH bond and the z(vertical) axis:

z
^   H
|  /
| /
C

Inspired from a function written by @jmelcr.

Parameters
  • C (numpy 1D-array) – Coordinates of C atom.

  • H (numpy 1D-array) – Coordinates of H atom.

Returns

The normalized vector.

Return type

float

buildh.geometry.calc_angle(atom1, atom2, atom3)#

Calculate the valence angle between atom1, atom2 and atom3.

Note

atom2 is the central atom.

Parameters
  • atom1 (numpy 1D-array.) –

  • atom2 (numpy 1D-array.) –

  • atom3 (numpy 1D-array.) –

Returns

The calculated angle in radians.

Return type

float

buildh.geometry.calc_rotation_matrix(quaternion)#

Translate a quaternion to a rotation matrix.

Parameters

quaternion (numpy 1D-array of 4 elements.) –

Returns

The rotation matrix.

Return type

numpy 2D-array (dimension [3, 3])

buildh.geometry.cross_product(A, B)#

Return the cross product between vectors A & B.

Source: http://hyperphysics.phy-astr.gsu.edu/hbase/vvec.html.

Note

On small vectors (i.e. of 3 elements), computing cross products with this functions is faster than np.cross().

Parameters
  • A (numpy 1D-array) – A vector of 3 elements.

  • B (numpy 1D-array) – Another vector of 3 elements.

Returns

Cross product of A^B.

Return type

numpy 1D-array

buildh.geometry.norm(vec)#

Return the norm of a vector.

Parameters

vec (numpy 1D-array) –

Returns

The magniture of the vector.

Return type

float

buildh.geometry.normalize(vec)#

Normalize a vector.

Parameters

vec (numpy 1D-array) –

Returns

The normalized vector.

Return type

numpy 1D-array

buildh.geometry.vec2quaternion(vec, theta)#

Translate a vector of 3 elements and angle theta to a quaternion.

Parameters
  • vec (numpy 1D-array) – Vector of the quaternion.

  • theta (float) – Angle of the quaternion in radian.

Returns

The full quaternion (4 elements).

Return type

numpy 1D-array