Module vectors
source code
Collection of functions for vector operations.
float
|
|
|
|
numpy float64 array
|
|
float
|
|
float
|
|
float
|
|
float
|
|
|
__package__ = ' lib.geometry '
|
Imports:
acos,
atan2,
cos,
pi,
sin,
array,
cross,
dot,
float64,
sqrt,
norm,
uniform
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>.
|
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.
|
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.
|
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.
|
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.
|