2012-05-22 35 views
0

我想寫在鎢數學 程序我們有兩個列表:W. Mathematica--圖形 - 製造球體

list1 = {Sphere[{x1}],Sphere[{x2}],Sphere[{x3}],Sphere[{x4}],Sphere[{x5}]} 
list2 = {Sphere[{y1}],Sphere[{y2}],Sphere[{y3}],Sphere[{y4}],Sphere[{y5}]} 

,我需要用氣瓶「畫」他們之間的結合,因此,我們必須有

list3={Cylinder[{x1,y1}],Cylinder[{x2,y2}],Cylinder[{x3,y3}],Cylinder[{x4,y4}],Cylinder[{x5,y5}]} 

我怎樣才能做到這一點自動使用任何列表:這樣的list1和list2?

+0

順便說一句,如果您有關於數學的其他問題,你可能要問他們過上的[專用StackExchange網站數學(http://mathematica.stackexchange.com/ )。 – Verbeia

回答

2

GraphPlot3D的文檔中有一個很好的例子,看起來好像它做了你想做的事情,儘管不是完全以你接近問題的方式。

1

你不指定圓柱體的半徑,我使用的是相對於第一個列表的圓柱體。

centers1 = {{1, 1, 1}, {2, 2, 2}, {3, 3, 3}}; 
radii1 = {0.2, 0.3, 0.4}; 
centers2 = {{1, -1, 1}, {2, -2, 2}, {3, -3, 3}}; 
radii2 = {0.3, 0.3, 0.3}; 

list1 = Sphere[Sequence @@ #] & /@ Transpose[{centers1, radii1}; 
list2 = Sphere[Sequence @@ #] & /@ Transpose[{centers2, radii2}]; 

Show[Graphics3D[{list1, list2, Cylinder[Sequence @@ #] & /@ Transpose[{Transpose[{centers1, centers2}], radii1}]}]] 

graphics3d