genepy3d.util package¶
Submodules¶
genepy3d.util.geo module¶
- genepy3d.util.geo.active_brownian_2d(n, v=1e-06, omega=0.0, p0=[0, 0], dt=0.001, R=1e-06, T=300.0, eta=0.001, seed_point=None)[source]¶
Generate an active Brownian motion in 2D.
- Parameters
n (int) – number of times of motion.
p0 (array of float) – init position.
v (float) – translation speed.
omega (float) – rotation speed.
dt (float) – time step.
R (float) – particle radius.
T (float) – environment temperature.
eta (float) – fluid viscocity.
- Returns
- A tuple containing
P (array of float): list of 2D positions.
t (array of float): corresponding times.
- genepy3d.util.geo.active_brownian_3d(n, v=1e-06, omega=0.0, p0=[0, 0, 0], dt=0.001, R=1e-06, T=300.0, eta=0.001, seed_point=None)[source]¶
Generate an active Brownian motion in 3D.
- Parameters
n (int) – number of times of motion.
p0 (array of float) – init position.
v (float) – translation speed.
omega (float) – rotation speed.
dt (float) – time step.
R (float) – particle radius.
T (float) – environment temperature.
eta (float) – fluid viscocity.
- Returns
- A tuple containing
P (array of float): list of 3D positions.
t (array of float): corresponding times.
- genepy3d.util.geo.angle3points(a, b, c)[source]¶
Return angle between three points where b is the center point.
- Parameters
a (array of float) – points in 3D.
b (array of float) – points in 3D.
c (array of float) – points in 3D.
- Returns
float.
- genepy3d.util.geo.emd(X, Y, return_flows=False)[source]¶
Compute Earth Mover’s Distance (EMD) between two nD points X and Y.
Installation detail is here: https://pythonot.github.io/all.html#ot.emd
- Parameters
X (nD array) – nD points.
Y (nD array) – nD points.
return_flows (bool) – if True return matching flows between X and Y.
- Returns
if return_flows is False, then only distance value else a tuple of distance and array of flows.
- genepy3d.util.geo.geo_len(P)[source]¶
Return geodesic length from a set of (ordered) points P in nD (n=2 or 3).
- Parameters
P (array of float) – list of points in nD (n=2 or 3).
- Returns
float.
- genepy3d.util.geo.norm(p)[source]¶
Norm of points.
- Parameters
p (array of float) – list of 3D points.
- Returns
array of float.
- genepy3d.util.geo.rotation_matrix(u, theta)[source]¶
Give the rotation matrix relative to a direction and an angle.
- Parameters
u (1d numpy array) – 3d vector for rotation direction.
theta (float) – rotation angle in radians.
- Returns
rotation matrix.
- Return type
(2d numpy array of shape (3,3))
- genepy3d.util.geo.vector2points(a, b, normalize=True)[source]¶
Compute vector from point a to point b with/without normalization.
genepy3d.util.plot module¶
- genepy3d.util.plot.fix_equal_axis(data)[source]¶
Fix equal axis bug in matplotlib 3d plot.
- Parameters
data (array of float) – 3D points.
- Returns
min and max values in each axis.
- genepy3d.util.plot.plot_line(ax, projection, x, y, z, scales=(1.0, 1.0, 1.0), line_args={})[source]¶
Support plotting a line.
- Parameters
ax – axis to be plotted.
projection (str) – support 3d, xy, xz, yz.
x (float) – x coordinate.
y (float) – y coordinate.
z (float) – z coordinate.
scales (tuple of float) – axis scales.
line_args (dic) – matplotlib args for line plot.
- genepy3d.util.plot.plot_point(ax, projection, x, y, z, scales=(1.0, 1.0, 1.0), point_args={})[source]¶
Support plotting points.
- Parameters
ax – axis to be plotted.
projection (str) – support 3d, xy, xz, yz.
x (float) – x coordinate.
y (float) – y coordinate.
z (float) – z coordinate.
scales (tuple(float)) – axis scales.
point_args (dic) – matplotlib args for points plot.