2016-10-24 48 views
1

下面我試圖繪製一個3維的棒子結。我想按照p1,p2,p3 ... p6或甚至1,2,3,... 6的順序標記每個點就足夠了。我怎麼做?如何添加點標籤到我的情節?

`

P1 = {0.300775, 1.301248, -0.702434} 
P2 = {-0.976281, -0.910795 , 0.701983} 
P3 = {0.976171, -0.910795, -0.702076} 
P4 = {-0.300495 , 1.300967, 0.702620} 
P5 = {-1.276451, -0.390204, -0.702474} 
P6 = {1.276282, -0.390420 , 0.702381} 
Knot = {P1, P2, P3, P4, P5, P6, P1} 
Show[ 
Graphics3D[Line[Knot]], 
Graphics3D[Point[Knot]], 
Axes -> True, 
AxesLabel -> {x, y, z}] 

`

這裏是輸出的畫面:

Trefoil Knot with sticks

回答

2
Show[Graphics3D[Line[Knot]], 
Graphics3D[ 
    MapIndexed[Text[Style["P" <> ToString[#2[[1]]], Medium, Red], #,{-1,-1}] &, 
    Knot[[;;-2]]]], Graphics3D[Point[Knot]], Axes -> True, 
AxesLabel -> {x, y, z}] 

enter image description here

不幸的是,它很難在3D中獲得文本,實際上看起來不錯。

這裏沒有風格的地圖使它更容易理解。

MapIndexed[Text["P" <> ToString[ #2[[1]] ], #] & 
+0

這看起來足夠我的用途。謝謝,你能向我解釋什麼是「和」嗎? – EgoKilla

+1

即*純函數*語法:https://reference.wolfram.com/language/tutorial/PureFunctions.html。 – agentp

相關問題