2012-05-03 55 views
2

我想在圓柱體上打印文本。結果應該看起來像一罐可口可樂。Mathematica:在3D圖形上打印文本

我嘗試了類似於例子Mathematica的文檔中: http://reference.wolfram.com/mathematica/ref/Texture.html>範圍>紋理規格>文本例

text = Style["Coca Cola", 128]; 
Graphics3D[{ 
    Texture[text], 
    Red, Cylinder[{{0, 0, 0}, {0, 0, h}}, radius[h], VertexTextureCoordinates -> {...}], 

}] 

但氣缸不識別VertexTextureCoordinates選項。 我在做什麼錯?

回答

3

你沒有做錯什麼,它只是不AFAIK內置原語的工作。但是,你一定能寫自己的Cylinder函數,它是由多邊形構建在那裏你可以申請任何你喜歡的質地:

text = Style["Cook a Cola", 128, White, Background -> Red]; 
Graphics3D[ 
{Texture[text], 
    Red, EdgeForm[], 
    With[{dphi = Pi/35}, 
    Table[ 
    Polygon[{{Cos[phi], Sin[phi], 0}, {Cos[phi + dphi], 
     Sin[phi + dphi], 0}, {Cos[phi + dphi], Sin[phi + dphi], 
     1}, {Cos[phi], Sin[phi], 1}}, 
    VertexTextureCoordinates -> {{phi/Pi, 0}, {(phi + dphi)/Pi, 
     0}, {(phi + dphi)/Pi, 1} 
     , {phi/Pi, 1}}], 
    {phi, 0, 2 Pi - dphi, dphi} 
    ] 
    ] 
    } 
] 

enter image description here

+0

謝謝。但我的教授希望我使用內置的基元。然而,這個文本的想法只是一個想法,以獲得額外的積分。 – Reini