Vectorizing the creation of 3D coordinates

How can I generate an array of all integer (x, y, z) points in the specified ranges of each axis without doing a triple loop? Something better than this ... (I looked at the meshgrid functions, but don't understand how to apply them here).

points = []
for i in range(-x,x):
    for j in range(-y,y):
        for k in range(-z,z):
            points.append((i,j,k))

      

+3
python numpy


source to share


No one has answered this question yet

See similar questions:

112
Using numpy to build an array of all combinations of two arrays
12
Creating numpy array of 3D coordinates from three 1D arrays
0
A more elegant way to create a list of 2D points in Python

or similar:

1509
Meaning of @classmethod and @staticmethod for beginners?
994
How do I return multiple values ​​from a function?
677
Detecting peaks in a 2D array
555
How to debug in Django, a good way?
471
How do I import a module by name as a string?
460
String comparison in Python: vs. ==
432
How do I use Python's itertools.groupby ()?
161
Get loop in Python FOR loop
126
Using python map and other functional tools
115
Check if item is in array



All Articles
Loading...
X
Show
Funny
Dev
Pics