[frames] | no frames]

Module vectors

source code

Collection of functions for vector operations.

 Functions
float
 complex_inner_product(v1=None, v2_conj=None) Calculate the inner product for the two complex vectors v1 and v2. source code

 random_unit_vector(vector) Generate a random rotation axis. source code
numpy float64 array
 unit_vector_from_2point(point1, point2) Generate the unit vector connecting point 1 to point 2. source code
float
 vector_angle_acos(vector1, vector2) Calculate the angle between two N-dimensional vectors using the acos formula. source code
float
 vector_angle_atan2(vector1, vector2) Calculate the angle between two N-dimensional vectors using the atan2 formula. source code
float
 vector_angle_complex_conjugate(v1=None, v2=None, v1_conj=None, v2_conj=None) Calculate the inter-vector angle between two complex vectors using the arccos formula. source code
float
 vector_angle_normal(vector1, vector2, normal) Calculate the directional angle between two N-dimensional vectors. source code
 Variables
__package__ = `'lib.geometry'`

Imports: acos, atan2, cos, pi, sin, array, cross, dot, float64, sqrt, norm, uniform

 Function Details

complex_inner_product(v1=None, v2_conj=None)

source code

Calculate the inner product <v1|v2> for the two complex vectors v1 and v2.

This is calculated as:

```              ___
<v1|v2> =   >   v1i . v2i* ,
/__
i
```

where * is the complex conjugate.

Parameters:
• `v1` (numpy rank-1 complex array) - The first vector.
• `v2_conj` (numpy rank-1 complex array) - The conjugate of the second vector. This is already in conjugate form to allow for non-standard definitions of the conjugate (for example Sm* = (-1)^m S-m).
Returns: float
The value of the inner product <v1|v2>.

random_unit_vector(vector)

source code

Generate a random rotation axis.

Uniform point sampling on a unit sphere is used to generate a random axis orientation.

Parameters:
• `vector` (numpy 3D, rank-1 array) - The 3D rotation axis.

unit_vector_from_2point(point1, point2)

source code

Generate the unit vector connecting point 1 to point 2.

Parameters:
• `point1` (list of float or numpy array) - The first point.
• `point2` (list of float or numpy array) - The second point.
Returns: numpy float64 array
The unit vector.

vector_angle_acos(vector1, vector2)

source code

Calculate the angle between two N-dimensional vectors using the acos formula.

The formula is:

```   angle = acos(dot(a / norm(a), b / norm(b))).
```
Parameters:
• `vector1` (numpy rank-1 array) - The first vector.
• `vector2` (numpy rank-1 array) - The second vector.
Returns: float
The angle between 0 and pi.

vector_angle_atan2(vector1, vector2)

source code

Calculate the angle between two N-dimensional vectors using the atan2 formula.

The formula is:

```   angle = atan2(norm(cross(a, b)), dot(a, b)).
```

This is more numerically stable for angles close to 0 or pi than the acos() formula.

Parameters:
• `vector1` (numpy rank-1 array) - The first vector.
• `vector2` (numpy rank-1 array) - The second vector.
Returns: float
The angle between 0 and pi.

vector_angle_complex_conjugate(v1=None, v2=None, v1_conj=None, v2_conj=None)

source code

Calculate the inter-vector angle between two complex vectors using the arccos formula.

The formula is:

```   theta = arccos(Re(<v1|v2>) / (|v1|.|v2|)) ,
```

where:

```              ___
\
<v1|v2> =   >   v1i . v2i* ,
/__
i
```

and:

```   |v1| = Re(<v1|v1>) .
```
Parameters:
• `v1` (numpy rank-1 complex array) - The first vector.
• `v2` (numpy rank-1 complex array) - The second vector.
• `v1_conj` (numpy rank-1 complex array) - The conjugate of the first vector. This is already in conjugate form to allow for non-standard definitions of the conjugate (for example Sm* = (-1)^m S-m).
• `v2_conj` (numpy rank-1 complex array) - The conjugate of the second vector. This is already in conjugate form to allow for non-standard definitions of the conjugate (for example Sm* = (-1)^m S-m).
Returns: float
The angle between 0 and pi.

vector_angle_normal(vector1, vector2, normal)

source code

Calculate the directional angle between two N-dimensional vectors.

Parameters:
• `vector1` (numpy rank-1 array) - The first vector.
• `vector2` (numpy rank-1 array) - The second vector.
• `normal` (numpy rank-1 array) - The vector defining the plane, to determine the sign.
Returns: float
The angle between -pi and pi.

 Generated by Epydoc 3.0.1 on Fri Jun 14 11:29:06 2019 http://epydoc.sourceforge.net