Generate an active Brownian motion in 3D. We adapted the algorithm of active brownian motion in 2D from the paper of Volpe et al. [1] for 3D case.
Parameters:
n (int) – number of positions generated from the simulation.
p0 (ndarray) – 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.
References
genepy3d.util.geo.emd(X, Y, return_flows=False)[source]#
Compute the Earth Mover’s Distance (EMD) [1] between two point clouds X and Y.
We used the emd func from POT library. Detail is here: https://pythonot.github.io/all.html#ot.emd
Parameters:
X (ndarray) – array of points.
Y (ndarray) – array of points.
return_flows (bool) – if True return travelled flows between X and Y.
Returns:
if return_flows is False, then only the emd distance is returned, otherwise a tuple of distance and array of flows.
Calculate the rotation matrix corresponding to a rotation of angle theta around a vector u in 3D.
Parameters:
u (ndarray) – 3D vector for rotation direction.
theta (float) – rotation angle in radians.
Returns:
rotation matrix.
Return type:
(ndarray of shape (3,3))
Examples
importnumpyasnpfromgenepy3d.utilimportgeou=np.array([1.,0.,0.])# unit x-vectortheta=np.pi/2.# rotation of 90 degreesM=geo.rotation_matrix(u,theta)# rotation matrix of 90 degrees around the unit x-vector
The option ax.axis(‘equal’) doesn’t seem to work in 3D. Assuming a plot of 3D point cloud. This function attemps to fix this issue.
Parameters:
data (ndarray) – 3D points.
Returns:
min and max values in each axis.
Notes
The returned values are then used in ax.set_xlim(), ax.set_ylim(), ax.set_zlim() to correct the unequal axis.
Examples
importnumpyasnpfromgenepy3d.utilimportplotasmyplimportmatplotlib.pyplotasplt# Coordinatesx=np.array([1.,50.,100.])y=np.array([1.,50.,100.])z=np.array([1.,50.,100.])# 3D plotfig=plt.figure()ax=fig.add_subplot(111,projection='3d')mypl.plot_point(ax,'3d',x,y,z)# Fix unequal axisdata=np.array([x,y,z]).T# array of points whose columns are x, y and z positionsparam=mypl.fix_equal_axis(data)ax.set_xlim(param['xmin'],param['xmax']);ax.set_ylim(param['ymin'],param['ymax']);ax.set_zlim(param['zmin'],param['zmax']);