Vector#
- brainmaze_utils.vector.get_mutual_vectors(x, y=None)#
Compute all pairwise difference vectors between points.
- Parameters:
x (numpy.ndarray) – Array of vectors with shape (n_points, n_dimensions)
y (array-like, optional) – Labels for the vectors. If provided, returns labels for each pair.
- Returns:
If y is None: array of all pairwise difference vectors If y is provided: tuple of (difference vectors, pair labels)
- Return type:
numpy.ndarray or tuple
- brainmaze_utils.vector.get_rot_2d(an)#
Get 2D rotation matrix for a given angle.
- Parameters:
an (float) – Rotation angle in degrees
- Returns:
2x2 rotation matrix
- Return type:
numpy.ndarray
- brainmaze_utils.vector.get_rot_3d(an)#
Get 3D rotation matrices for given angles around x, y, and z axes.
- Parameters:
an (array-like) – Array of 3 rotation angles [x, y, z] in degrees
- Returns:
List of three 3x3 rotation matrices [Rx, Ry, Rz]
- Return type:
list
- brainmaze_utils.vector.get_rot_3d_x(an)#
Get 3D rotation matrix for rotation around the x-axis.
- Parameters:
an (float) – Rotation angle in degrees
- Returns:
3x3 rotation matrix for x-axis rotation
- Return type:
numpy.ndarray
- brainmaze_utils.vector.get_rot_3d_y(an)#
Get 3D rotation matrix for rotation around the y-axis.
- Parameters:
an (float) – Rotation angle in degrees
- Returns:
3x3 rotation matrix for y-axis rotation
- Return type:
numpy.ndarray
- brainmaze_utils.vector.get_rot_3d_z(an)#
Get 3D rotation matrix for rotation around the z-axis.
- Parameters:
an (float) – Rotation angle in degrees
- Returns:
3x3 rotation matrix for z-axis rotation
- Return type:
numpy.ndarray
- brainmaze_utils.vector.rotate(x, angl)#
Rotate vectors by specified angle(s) around their mean.
- Parameters:
x (numpy.ndarray) – Array of vectors with shape (n_points, 2) or (n_points, 3)
angl (float or array-like) – For 2D: single rotation angle in degrees For 3D: array of 3 rotation angles [x, y, z] in degrees
- Returns:
Rotated vectors
- Return type:
numpy.ndarray
- brainmaze_utils.vector.scale(x, m)#
Scale vectors around their mean by given factors.
- Parameters:
x (numpy.ndarray) – Array of vectors with shape (n_points, n_dimensions)
m (array-like) – Scale factors for each dimension
- Returns:
Scaled vectors
- Return type:
numpy.ndarray
- brainmaze_utils.vector.translate(x, m)#
Translate vectors by given offsets.
- Parameters:
x (numpy.ndarray) – Array of vectors with shape (n_points, n_dimensions)
m (array-like) – Translation offsets for each dimension
- Returns:
Translated vectors
- Return type:
numpy.ndarray