line_segment#

Calculates the voxel coordinates of a straight line between the two given end points

import inspect

import matplotlib.pyplot as plt
import numpy as np

import porespy as ps

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.

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/e7ba75b50351f79939789e324cdd495e34a7d9a179360af73e30e49c7df5b83f.png