Skip to content

Instantly share code, notes, and snippets.

@mstankie
Created April 8, 2022 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstankie/4fcd8e3ac2e4a16b28e97f3a969c10e6 to your computer and use it in GitHub Desktop.
Save mstankie/4fcd8e3ac2e4a16b28e97f3a969c10e6 to your computer and use it in GitHub Desktop.
Generate (x,y,z) coordinates of N points arranged on 3D grid as Nx3 NumPy array
import numpy as np
x_coords = np.arange(3)
y_coords = np.linspace(-1, 1, 11)
z_coords = [0.0, 0.5, 1.0]
point_grid = np.hstack([c.reshape(-1, 1) for c in np.meshgrid(x_coords, y_coords, z_coords)])
@mstankie
Copy link
Author

mstankie commented Apr 8, 2022

This may be extended by adding coordinates for other dimensions to meshgrid function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment