atomlib.vec
Helper functions for spatial vectors.
to_vec3
Broadcast and coerce v
to a Vec3
of type dtype
.
Source code in atomlib/types.py
dot
Take the dot product between two vectors, along axis axis
.
Source code in atomlib/vec.py
norm
perp
Return the component of v1
perpendicular to v2
.
para
Return the component of v1
parallel to v2
.
is_diagonal
Return if matrix
is diagonal, to tolerance tol
.
Source code in atomlib/vec.py
split_arr
polygon_solid_angle
polygon_solid_angle(
poly: ArrayLike,
pts: Optional[ArrayLike] = None,
winding: Optional[ArrayLike] = None,
) -> NDArray[float64]
Return the signed solid angle of the polygon poly
in the xy plane, as viewed from pts
.
PARAMETER | DESCRIPTION |
---|---|
poly
|
Polygon(s) to compute the angle of, array of shape
TYPE:
|
pts
|
Point(s) to view the polygons from, array of shape |
RETURNS | DESCRIPTION |
---|---|
NDArray[float64]
|
A ndarray of shape |
Source code in atomlib/vec.py
polygon_winding
Return the winding number of the given 2d polygon poly
around the point pt
.
If pt
is not specified, return the polygon's total winding number (turning number).
Vectorized. CCW winding is defined as positive.
Source code in atomlib/vec.py
in_polygon
in_polygon(
poly: ndarray,
pt: Literal[None] = None,
*,
rule: WindingRule = "evenodd"
) -> Callable[[ndarray], NDArray[bool_]]
in_polygon(
poly: ndarray,
pt: ndarray,
*,
rule: WindingRule = "evenodd"
) -> NDArray[bool_]
in_polygon(
poly: ndarray,
pt: Optional[ndarray] = None,
*,
rule: WindingRule = "evenodd"
) -> Union[
NDArray[bool_], Callable[[ndarray], NDArray[bool_]]
]
Return whether pt
is in poly
, under the given winding rule.
In the one-argument form, return a closure which tests poly
for the given point.
Source code in atomlib/vec.py
reduce_vec
Reduce a crystallographic vector (int or float) to lowest common terms.
Examples
Source code in atomlib/vec.py
miller_4_to_3_vec
miller_4_to_3_vec(
a: NDArray[number],
reduce: bool = True,
max_denom: int = 10000,
) -> NDArray[number]
Convert a vector in 4-axis Miller-Bravais notation to 3-axis Miller notation.
Source code in atomlib/vec.py
miller_3_to_4_vec
miller_3_to_4_vec(
a: NDArray[number],
reduce: bool = True,
max_denom: int = 10000,
) -> NDArray[number]
Convert a vector in 3-axis Miller notation to 4-axis Miller-Bravais notation.
Source code in atomlib/vec.py
miller_4_to_3_plane
miller_4_to_3_plane(
a: NDArray[number],
reduce: bool = True,
max_denom: int = 10000,
) -> NDArray[number]
Convert a plane in 4-axis Miller-Bravais notation to 3-axis Miller notation.
Source code in atomlib/vec.py
miller_3_to_4_plane
miller_3_to_4_plane(
a: NDArray[number],
reduce: bool = True,
max_denom: int = 10000,
) -> NDArray[number]
Convert a plane in 3-axis Miller notation to 4-axis Miller-Bravais notation.