locan.utils.rotation.Rotation2D¶
- class locan.utils.rotation.Rotation2D(angle_in_radians, rotation_matrix)[source]¶
Bases:
objectRotation in 2 dimensions.
This class provides an interface to initialize from and represent rotations with rotation matrices, angles, and unit vectors.
To create Rotation objects use from_… methods. Rotation(…) is not supposed to be instantiated directly.
This function follows the interface of class:scipy.spatial.transform.Rotation that can be applied in 3D.
See also
class:scipy.spatial.transform.Rotation class:Rotation3D
Methods
__init__(angle_in_radians, rotation_matrix)align_vectors(vector[, other_vector])Estimate a rotation to optimally align other_vector with vector.
apply(vectors)Apply this rotation to 2-dimensional vectors.
as_angle([degrees])Return the rotation angle.
Return the rotation matrix.
from_angle(angle[, degrees])Initialize from rotation angle.
from_matrix(matrix)Initialize from rotation matrix.
inv()Provide an instance with the inverted rotation (with a rotation matrix that is equal to the transposed matrix).
Attributes
- classmethod align_vectors(vector, other_vector=(1, 0))[source]¶
Estimate a rotation to optimally align other_vector with vector.
- Parameters:
vector (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[bool|int|float|complex|str|bytes]]) – 2-dimensional vectorother_vector (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[bool|int|float|complex|str|bytes]]) – 2-dimensional vector
- Return type:
- apply(vectors)[source]¶
Apply this rotation to 2-dimensional vectors.
- Parameters:
vectors (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[bool|int|float|complex|str|bytes]]) – One or more 2-dimensional vectors on which to apply the rotation.- Return type:
npt.NDArray[np.float64]
- as_angle(degrees=False)[source]¶
Return the rotation angle.
- Parameters:
degrees (
bool) – If true the angle is given in degrees, else in radians.- Return type:
float
- classmethod from_angle(angle, degrees=False)[source]¶
Initialize from rotation angle.
- Parameters:
angle (
float) – Angle between x-axis and counter-clockwise rotated axis.degrees (
bool) – If true, angle is in degrees else in radians.
- Return type:
- classmethod from_matrix(matrix)[source]¶
Initialize from rotation matrix.
- Parameters:
matrix (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],bool,int,float,complex,str,bytes,_NestedSequence[bool|int|float|complex|str|bytes]]) – Valid 2-dimensional rotation matrix- Return type:
- inv()[source]¶
Provide an instance with the inverted rotation (with a rotation matrix that is equal to the transposed matrix).
- Return type:
- property matrix: ndarray[tuple[int, ...], dtype[float64]]¶