Wolfram语言190字节
下面的代码根据实际坐标返回所有图形边缘(假设每个迷你立方体的边缘为2个单位,并且魔方的原点为左下角顶点)。
t=Table;h[a_,b_,c_]:=t[{x,y,z},{a,1,5,2},{b,1,5,2},{c,0,6,6}];Partition[Sort[a=Cases[DeleteCases[Tuples[Flatten[{h[x,z,y],h[y,z,x],h[x,y,z]},3],{2}],{x_,x_}],x_/;ManhattanDistance@@x==2]],4]
(* output *)
{{{{0,1,1},{0,1,3}},{{0,1,1},{0,3,1}},{{0,1,1},{1,0,1}},{{0,1,1},{1,1,0}}},{{{0,1,3},{0,1,1}},{{0,1,3},{0,1,5}},{{0,1,3},{0,3,3}},{{0,1,3},{1,0,3}}},{{{0,1,5},{0,1,3}},{{0,1,5},{0,3,5}},{{0,1,5},{1,0,5}},{{0,1,5},{1,1,6}}},{{{0,3,1},{0,1,1}},{{0,3,1},{0,3,3}},{{0,3,1},{0,5,1}},{{0,3,1},{1,3,0}}},{{{0,3,3},{0,1,3}},{{0,3,3},{0,3,1}},{{0,3,3},{0,3,5}},{{0,3,3},{0,5,3}}},{{{0,3,5},{0,1,5}},{{0,3,5},{0,3,3}},{{0,3,5},{0,5,5}},{{0,3,5},{1,3,6}}},{{{0,5,1},{0,3,1}},{{0,5,1},{0,5,3}},{{0,5,1},{1,5,0}},{{0,5,1},{1,6,1}}},{{{0,5,3},{0,3,3}},{{0,5,3},{0,5,1}},{{0,5,3},{0,5,5}},{{0,5,3},{1,6,3}}},{{{0,5,5},{0,3,5}},{{0,5,5},{0,5,3}},{{0,5,5},{1,5,6}},{{0,5,5},{1,6,5}}},{{{1,0,1},{0,1,1}},{{1,0,1},{1,0,3}},{{1,0,1},{1,1,0}},{{1,0,1},{3,0,1}}},{{{1,0,3},{0,1,3}},{{1,0,3},{1,0,1}},{{1,0,3},{1,0,5}},{{1,0,3},{3,0,3}}},{{{1,0,5},{0,1,5}},{{1,0,5},{1,0,3}},{{1,0,5},{1,1,6}},{{1,0,5},{3,0,5}}},{{{1,1,0},{0,1,1}},{{1,1,0},{1,0,1}},{{1,1,0},{1,3,0}},{{1,1,0},{3,1,0}}},{{{1,1,6},{0,1,5}},{{1,1,6},{1,0,5}},{{1,1,6},{1,3,6}},{{1,1,6},{3,1,6}}},{{{1,3,0},{0,3,1}},{{1,3,0},{1,1,0}},{{1,3,0},{1,5,0}},{{1,3,0},{3,3,0}}},{{{1,3,6},{0,3,5}},{{1,3,6},{1,1,6}},{{1,3,6},{1,5,6}},{{1,3,6},{3,3,6}}},{{{1,5,0},{0,5,1}},{{1,5,0},{1,3,0}},{{1,5,0},{1,6,1}},{{1,5,0},{3,5,0}}},{{{1,5,6},{0,5,5}},{{1,5,6},{1,3,6}},{{1,5,6},{1,6,5}},{{1,5,6},{3,5,6}}},{{{1,6,1},{0,5,1}},{{1,6,1},{1,5,0}},{{1,6,1},{1,6,3}},{{1,6,1},{3,6,1}}},{{{1,6,3},{0,5,3}},{{1,6,3},{1,6,1}},{{1,6,3},{1,6,5}},{{1,6,3},{3,6,3}}},{{{1,6,5},{0,5,5}},{{1,6,5},{1,5,6}},{{1,6,5},{1,6,3}},{{1,6,5},{3,6,5}}},{{{3,0,1},{1,0,1}},{{3,0,1},{3,0,3}},{{3,0,1},{3,1,0}},{{3,0,1},{5,0,1}}},{{{3,0,3},{1,0,3}},{{3,0,3},{3,0,1}},{{3,0,3},{3,0,5}},{{3,0,3},{5,0,3}}},{{{3,0,5},{1,0,5}},{{3,0,5},{3,0,3}},{{3,0,5},{3,1,6}},{{3,0,5},{5,0,5}}},{{{3,1,0},{1,1,0}},{{3,1,0},{3,0,1}},{{3,1,0},{3,3,0}},{{3,1,0},{5,1,0}}},{{{3,1,6},{1,1,6}},{{3,1,6},{3,0,5}},{{3,1,6},{3,3,6}},{{3,1,6},{5,1,6}}},{{{3,3,0},{1,3,0}},{{3,3,0},{3,1,0}},{{3,3,0},{3,5,0}},{{3,3,0},{5,3,0}}},{{{3,3,6},{1,3,6}},{{3,3,6},{3,1,6}},{{3,3,6},{3,5,6}},{{3,3,6},{5,3,6}}},{{{3,5,0},{1,5,0}},{{3,5,0},{3,3,0}},{{3,5,0},{3,6,1}},{{3,5,0},{5,5,0}}},{{{3,5,6},{1,5,6}},{{3,5,6},{3,3,6}},{{3,5,6},{3,6,5}},{{3,5,6},{5,5,6}}},{{{3,6,1},{1,6,1}},{{3,6,1},{3,5,0}},{{3,6,1},{3,6,3}},{{3,6,1},{5,6,1}}},{{{3,6,3},{1,6,3}},{{3,6,3},{3,6,1}},{{3,6,3},{3,6,5}},{{3,6,3},{5,6,3}}},{{{3,6,5},{1,6,5}},{{3,6,5},{3,5,6}},{{3,6,5},{3,6,3}},{{3,6,5},{5,6,5}}},{{{5,0,1},{3,0,1}},{{5,0,1},{5,0,3}},{{5,0,1},{5,1,0}},{{5,0,1},{6,1,1}}},{{{5,0,3},{3,0,3}},{{5,0,3},{5,0,1}},{{5,0,3},{5,0,5}},{{5,0,3},{6,1,3}}},{{{5,0,5},{3,0,5}},{{5,0,5},{5,0,3}},{{5,0,5},{5,1,6}},{{5,0,5},{6,1,5}}},{{{5,1,0},{3,1,0}},{{5,1,0},{5,0,1}},{{5,1,0},{5,3,0}},{{5,1,0},{6,1,1}}},{{{5,1,6},{3,1,6}},{{5,1,6},{5,0,5}},{{5,1,6},{5,3,6}},{{5,1,6},{6,1,5}}},{{{5,3,0},{3,3,0}},{{5,3,0},{5,1,0}},{{5,3,0},{5,5,0}},{{5,3,0},{6,3,1}}},{{{5,3,6},{3,3,6}},{{5,3,6},{5,1,6}},{{5,3,6},{5,5,6}},{{5,3,6},{6,3,5}}},{{{5,5,0},{3,5,0}},{{5,5,0},{5,3,0}},{{5,5,0},{5,6,1}},{{5,5,0},{6,5,1}}},{{{5,5,6},{3,5,6}},{{5,5,6},{5,3,6}},{{5,5,6},{5,6,5}},{{5,5,6},{6,5,5}}},{{{5,6,1},{3,6,1}},{{5,6,1},{5,5,0}},{{5,6,1},{5,6,3}},{{5,6,1},{6,5,1}}},{{{5,6,3},{3,6,3}},{{5,6,3},{5,6,1}},{{5,6,3},{5,6,5}},{{5,6,3},{6,5,3}}},{{{5,6,5},{3,6,5}},{{5,6,5},{5,5,6}},{{5,6,5},{5,6,3}},{{5,6,5},{6,5,5}}},{{{6,1,1},{5,0,1}},{{6,1,1},{5,1,0}},{{6,1,1},{6,1,3}},{{6,1,1},{6,3,1}}},{{{6,1,3},{5,0,3}},{{6,1,3},{6,1,1}},{{6,1,3},{6,1,5}},{{6,1,3},{6,3,3}}},{{{6,1,5},{5,0,5}},{{6,1,5},{5,1,6}},{{6,1,5},{6,1,3}},{{6,1,5},{6,3,5}}},{{{6,3,1},{5,3,0}},{{6,3,1},{6,1,1}},{{6,3,1},{6,3,3}},{{6,3,1},{6,5,1}}},{{{6,3,3},{6,1,3}},{{6,3,3},{6,3,1}},{{6,3,3},{6,3,5}},{{6,3,3},{6,5,3}}},{{{6,3,5},{5,3,6}},{{6,3,5},{6,1,5}},{{6,3,5},{6,3,3}},{{6,3,5},{6,5,5}}},{{{6,5,1},{5,5,0}},{{6,5,1},{5,6,1}},{{6,5,1},{6,3,1}},{{6,5,1},{6,5,3}}},{{{6,5,3},{5,6,3}},{{6,5,3},{6,3,3}},{{6,5,3},{6,5,1}},{{6,5,3},{6,5,5}}},{{{6,5,5},{5,5,6}},{{6,5,5},{5,6,5}},{{6,5,5},{6,3,5}},{{6,5,5},{6,5,3}}}}
在每个外部面上生成点的工作由函数完成h
。必须调用3次才能生成x = 0,x = 6的点;y = 0,y = 6;并且z = 0,z = 6。
到彼此之间的曼哈顿单位距离为2个单位的每个构面点将连接到相应的点。
我们可以通过以下方式直观地显示图形边缘:a
是图形边缘的列表,下面以箭头表示。
Graphics3D[{Arrowheads[.02],Arrow/@a},Boxed->False,Axes-> True]
下图显示了魔方,外部面上的点和8个图形边缘。
红点位于y = 0和y = 6的小平面上;蓝色和灰色点分别位于x = 6和x = 0的小平面上;黑点位于z = 6和z = 0的小平面上。