首页 > 解决方案 > How do I create an array of 3D coordinates in Python?

问题描述

I was wondering what would be an efficient way to create an array of coordinates of a 3d space. For example:

[ [x,y,z] ,for x in range(1000) for y in range(1000) for z in range(1000) ]

will take allot of time.

标签: python

解决方案


您可以使用 Numpy 和 mgrid 函数:https ://docs.scipy.org/doc/numpy/reference/generated/numpy.mgrid.html

但主要问题是您分配了大量内存,这总是很慢。也许您可以编写具有较小分辨率的程序并一次执行 10 步?


推荐阅读