component_model.utils.transform¶
Functions
|
Turn the vector 'vec' given in cartesian coordinates into cylindrical coordinates. |
|
Turn the vector 'vec' given in cartesian coordinates into spherical coordinates. |
|
Turn cylinder coordinate vector 'vec' (defined according to ISO (r,phi,z)) into cartesian coordinates. |
|
Rotate the spherical vector vec using the Euler angles (yaw,pitch,roll). |
|
Return the normalized vector. |
|
Turn a 4-tuple, consisting of quantity (float) and a direction 3-vector to a direction 3-vector, where the norm denotes the direction and the length denotes the quantity. |
|
Return a scipy Rotation object from the spherical coordinates vec, i.e. the rotation which turns a vector along the z-axis into vec. |
|
Find the rotation object which rotates vec1 into vec2. |
|
Turn spherical vector 'vec' (defined according to ISO 80000-2 (r,polar,azimuth)) into cartesian coordinates. |
|
- component_model.utils.transform.cartesian_to_cylindrical(vec: ndarray | tuple[float, ...], deg: bool = False) ndarray¶
Turn the vector ‘vec’ given in cartesian coordinates into cylindrical coordinates. (defined according to ISO, (r, phi, z), with phi right-handed wrt. x-axis).
- component_model.utils.transform.cartesian_to_spherical(vec: ndarray | tuple[float, ...], deg: bool = False) ndarray¶
Turn the vector ‘vec’ given in cartesian coordinates into spherical coordinates. (defined according to ISO 80000-2, (r, polar, azimuth)).
- component_model.utils.transform.cylindrical_to_cartesian(vec: ndarray | tuple[float, ...], deg: bool = False) ndarray¶
Turn cylinder coordinate vector ‘vec’ (defined according to ISO (r,phi,z)) into cartesian coordinates. The angle phi is measured with respect to x-axis, right hand.
- component_model.utils.transform.euler_rot_spherical(rpy: tuple[float, ...] | list[float] | Rotation, vec: tuple[float, ...] | list[float] | None = None, seq: str = 'XYZ', degrees: bool = False) ndarray¶
Rotate the spherical vector vec using the Euler angles (yaw,pitch,roll).
- Parameters:
rpy (Sequence|Rotation) – The sequence of (yaw,pitch,roll) Euler angles or the pre-calculated Rotation object
vec – (Sequence): the spherical vector to be rotated None: Use unit vector in z-direction, i.e. (1,0,0) 2-sequence: only polar and azimuth provided and returned => (polar,azimuth) 3-sequence: (r,polar,azimuth)
seq (str) – Sequence of rotations as defined in scipy.spatial.transform.Rotation.from_euler()
degrees (bool) – angles optionally provided in degrees. Default: radians
- Returns:
The rotated vector in spherical coordinates (radius only if 3-vector is provided)
- component_model.utils.transform.normalized(vec: ndarray) ndarray¶
Return the normalized vector. Helper function.
- component_model.utils.transform.quantity_direction(quantity_direction: tuple[float, ...], spherical: bool = False, deg: bool = False) ndarray¶
Turn a 4-tuple, consisting of quantity (float) and a direction 3-vector to a direction 3-vector, where the norm denotes the direction and the length denotes the quantity. The return vector is always a cartesian vector.
- Parameters:
quantity_direction (tuple) – a 4-tuple consisting of the desired length of the resulting vector (in standard units (m or m/s)) and the direction 3-vector (in standard units)
spherical (bool) – Optional possibility to provide the input direction vector in spherical coordinates
deg (bool) – Optional possibility to provide the input angle (of spherical coordinates) in degrees. Only relevant if spherical=True
- component_model.utils.transform.rot_from_spherical(vec: tuple[float, ...] | list[float] | ndarray, degrees: bool = False) Rotation¶
Return a scipy Rotation object from the spherical coordinates vec, i.e. the rotation which turns a vector along the z-axis into vec.
- Parameters:
vec (Sequence | np.ndarray) – a spherical vector as 3D or 2D (radius omitted)
degrees (bool) – optional possibility to provide angles in degrees
- component_model.utils.transform.rot_from_vectors(vec1: ndarray, vec2: ndarray) Rotation¶
Find the rotation object which rotates vec1 into vec2. Lengths of vec1 and vec2 shall be equal.
- component_model.utils.transform.spherical_to_cartesian(vec: ndarray | tuple[float, ...], deg: bool = False) ndarray¶
Turn spherical vector ‘vec’ (defined according to ISO 80000-2 (r,polar,azimuth)) into cartesian coordinates.
- component_model.utils.transform.spherical_unique(vec: ndarray, eps: float = 1e-10) ndarray¶