line_segment
¶
Calculates the voxel coordinates of a straight line between the two given end points
import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import inspect
inspect.signature(ps.generators.line_segment)
<Signature (X0, X1)>
Given a list a pair of end points, it returns tuples indicating which voxels to fill in order to draw a straight line between them, for each dimenstion.
Generate line segment:¶
X0 = [1, 20]
X1 = [10, 1]
xs, ys = ps.generators.line_segment(X0=X0, X1=X1)
im = np.zeros([25, 25], dtype=bool)
im[xs, ys] = True
fig, ax = plt.subplots(1, 1, figsize=[4, 4])
ax.imshow(im, interpolation='none', origin='lower')
ax.axis(False);
