3D rotations and translations of coordinates
This module contains function to rotate and translate 3D cartesian coordinates.
snow.misc.rototranslation
ax_from_two_points(coord_pt_1, coord_pt_2)
get the vector connecting two points, oriented from the first to the second.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coord_pt_1
|
ndarray or list
|
coordinates of the first point |
required |
coord_pt_2
|
ndarray or list
|
coordinates of the second point |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ax_connecting |
ndarray
|
vector connecting the two points |
Source code in snow/misc/rototranslation.py
translate_com_to_origin(coords, elements=None)
Shifts the positions to the center of mass reference system (so that the center of mass is in the origin).
If elements are provided, a mass-weighted average of positions is performed, otherwise (elements=None), a simple geometrical average is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
Array of atomic coordinates |
required |
elements
|
list
|
List of element symbols corresponding to the atoms. Default to None. If None, all positions will have the same weight in the calculation of the center of mass |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
new_coords |
ndarray
|
shifted coords |
Source code in snow/misc/rototranslation.py
rotate_around_ax(coords, axis, angle)
Rotate coordinates around a given axis by a given angle (in radians).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
(array - like, shape(..., 3))
|
Coordinates to rotate. |
required |
axis
|
(array - like, shape(3))
|
Rotation axis. |
required |
angle
|
float
|
Rotation angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
new_coords |
ndarray
|
Rotated coordinates, same shape as input. |
Source code in snow/misc/rototranslation.py
align_axis_to_z(coords, axis)
Rotates the system so that the provided axis is aligned with the z=(0,0,1) axis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
Array of the atomic coordinates |
required |
axis
|
ndarray
|
axis to become the new z-axis of the coordinates |
required |
Returns:
| Name | Type | Description |
|---|---|---|
new_coords |
ndarray
|
The transformed coordinates |
Source code in snow/misc/rototranslation.py
align_z_to_axis(coords, axis)
Rotates the system so that the original z-axis of the system is aligned with the provided axis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
Array of the atomic coordinates |
required |
axis
|
ndarray
|
axis to become the new z-axis of the coordinates |
required |
Returns:
| Name | Type | Description |
|---|---|---|
new_coords |
ndarray
|
The transformed coordinates |