我有一些代码,使用元组的坐标在3d空间中绘制一个多维数据集。我想通过获取点的所有可能组合并绘制所有三角形来向多维数据集中添加面。任何想法如何执行此操作,或者有更好的方法。
有什么帮助,
谢谢!
#the points I use to make the cube
points = [( 1, 1, 1), ( 1, -1, 1),
(-1, -1, 1), (-1, 1, 1),
( 1, 1, -1), ( 1, -1, -1),
(-1, -1, -1), (-1, 1, -1)]
答案 0 :(得分:0)
from itertools import product
def getAllCombos(my_list):
return list(product(*((x, -x) for x in my_list)))
my_list = [1,1,1]
result = getAllCombos(my_list)
print(result)
此打印:[(1, 1, 1), (1, 1, -1), (1, -1, 1), (1, -1, -1), (-1, 1, 1), (-1, 1, -1), (-1, -1, 1), (-1, -1, -1)]