Helpers#
- R_2vect(vector_orig, vector_fin)#
Calculate the rotation matrix to rotate from one vector to another.
- Parameters:
- vector_origndarray
Original vector, shape (3,).
- vector_finndarray
Final vector, shape (3,).
- Returns:
- Rndarray
Rotation matrix of shape (3, 3).
Notes
The rotation matrix is determined based on the cross product of the two vectors and the rotation angle.
- create_sphere_points(radius, x0, y0, z0, n=72)#
Create 3D points that fall on a defined sphere.
- Parameters:
- radiusfloat
Radius of the sphere.
- x0float
X-coordinate of the sphere center.
- y0float
Y-coordinate of the sphere center.
- z0float
Z-coordinate of the sphere center.
- nint, optional
Number of angle slices. 2*pi angle range is evenly split into n slices. Default is 72.
- Returns:
- positions_xyzndarray
Coordinates of 3D points on the sphere, shape (n*n, 3).
References
- lstsq_sphere_fitting(positions)#
Fit a set of 3D points to a sphere using least squares.
- Parameters:
- positionsndarray
A 2D array of shape (n, 3) where each row represents a 3D coordinate (x, y, z).
- Returns:
- float
Radius of the fitted sphere.
- float
X-coordinate of the sphere center.
- float
Y-coordinate of the sphere center.
- float
Z-coordinate of the sphere center.
Notes
The function constructs a matrix A based on the positions and uses least squares to determine the sphere’s parameters.
References
- make_plot_array(xmin, xmax, ymin, ymax, interp=0.1)#
Create a meshgrid based on the given boundaries and interpolation factor.
- Parameters:
- xminfloat
Minimum x value.
- xmaxfloat
Maximum x value.
- yminfloat
Minimum y value.
- ymaxfloat
Maximum y value.
- interpfloat, optional
Interpolation factor, less than 1 for downsampling. Default is 0.1.
- Returns:
- xxndarray
2D array of x-coordinates for the meshgrid.
- yyndarray
2D array of y-coordinates for the meshgrid.
- plane_fit(atom_coordinates, order=1)#
Fit a plane to given atom coordinates.
- Parameters:
- atom_coordinatesndarray
A 2D array of shape (n, 3) where each row is a 3D coordinate (x, y, z).
- orderint, optional
Order of the plane fit. 1 indicates linear and 2 indicates quadratic. Default is 1.
- Returns:
- Xndarray
2D array of x-coordinates for the meshgrid.
- Yndarray
2D array of y-coordinates for the meshgrid.
- Zndarray
2D array of z-coordinates for the meshgrid.
Notes
The function uses least squares to fit a plane to the input coordinates.
ColabSegNapariWidget#
|
A widget for napari viewer to manage and visualize data from ColabSegData instances. |
NapariManager#
|
Manages the napari viewer and associated widgets for data visualization and interaction. |