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);
../../../_images/a0c2805372e26207e49f7d9c9bf7dc80b99ba78a15445ef2a448f02427bbcd67.png